contacts_plat/cca_launch_api/inc/mccaconnection.h
changeset 0 e686773b3f54
equal deleted inserted replaced
-1:000000000000 0:e686773b3f54
       
     1 /*
       
     2 * Copyright (c) 2007 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:  This is a class for launching CCA application. 
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef M_MCCACONNECTION_H
       
    20 #define M_MCCACONNECTION_H
       
    21 
       
    22 #include <e32std.h>
       
    23 
       
    24 class MCCAParameter;
       
    25 
       
    26 /** @file mccaconnection.h
       
    27  *
       
    28  *  MCCAObserver is used to get notifications from CCA application.
       
    29  *
       
    30  *  @lib ccaclient
       
    31  *  @since S60 v5.0
       
    32  */
       
    33 class MCCAObserver
       
    34     {
       
    35 public:
       
    36 
       
    37     enum TNotifyType
       
    38         {
       
    39         /* EExitEvent is used to indicate that the CCA application has been
       
    40          * closed. Accompanied parameter aReason will either be an error code 
       
    41          * or the command id that was used to close the CCA application.
       
    42          */
       
    43         EExitEvent
       
    44         };
       
    45 
       
    46     /**
       
    47      * This callback is to get simple notifications from CCA application.
       
    48      *
       
    49      * @since S60 5.0
       
    50      * @param aType describes the notify type (see TNotifyType)
       
    51      * @param aReason describes the reason (see events in TNotifyType)
       
    52      */
       
    53     virtual void CCASimpleNotifyL( TNotifyType aType, TInt aReason ) = 0;
       
    54 
       
    55     /**
       
    56      * Returns an extension point for this interface or NULL.
       
    57      * @param aExtensionUid Uid of extension
       
    58      * @return Extension point or NULL
       
    59      */
       
    60     virtual TAny* CcaObserverExtension( 
       
    61             TUid /*aExtensionUid*/ ) { return NULL; }
       
    62 
       
    63 protected:  // Destructor
       
    64     /**
       
    65      * Destructor.
       
    66      */
       
    67     virtual ~MCCAObserver() { }
       
    68 
       
    69     };
       
    70 
       
    71 /** @file mccaconnection.h
       
    72  *  MCCAConnection is used to start a actual launching of CCA application over the AppServer framwork. 
       
    73  *  Before starting the launching, the parameter class have to be instantiated and set to ready 
       
    74  *  with the proper contact data. 
       
    75  *  @see MCCAParameter
       
    76  *
       
    77  *  Example usage of the API:  
       
    78  *  @code
       
    79  *  Header file:
       
    80  *   
       
    81  *  // Launching can be done without MCCAObserver-interface,
       
    82  *  // then the iConnection can be closed in destructor etc when
       
    83  *  // CCApplication is already closed
       
    84  *  class CMyClass : public CBase, public MCCAObserver
       
    85  *  {
       
    86  *  ...
       
    87  *  MCCAConnection* iConnection;
       
    88  *  };
       
    89  *
       
    90  *  
       
    91  *  Source file:
       
    92  *  ...
       
    93  *  // Launch the CCApplication  
       
    94  *  MCCAParameter* parameter = TCCAFactory::NewParameterL();
       
    95  *  CleanupClosePushL( *parameter );
       
    96  *  // prepare parameter here (see details from the header)
       
    97  *  if ( !iConnection )
       
    98  *      {// get connection
       
    99  *      iConnection = TCCAFactory::NewConnectionL();
       
   100  *      }
       
   101  *  // note; there can be only one CCApplication instance
       
   102  *  // running simultaneously per iConnection
       
   103  *  iConnection->LaunchAppL( *parameter );
       
   104  *  OR
       
   105  *  iConnection->LaunchAppL( *parameter, this );
       
   106  *  CleanupStack::Pop();// parameter is taken care by iConnection
       
   107  *  ...
       
   108  *  ~CMyClass::CMyClass()
       
   109  *  {
       
   110  *  ...
       
   111  *  if ( iConnection )
       
   112  *      {// close connection
       
   113  *      iConnection->Close();
       
   114  *      }
       
   115  *  } 
       
   116  *  ...
       
   117  *  // If MCCAObserver-interface is used, it could be implemented like this
       
   118  *  void CMyClass::CCASimpleNotifyL( TNotifyType aType, TInt aReason )
       
   119  *  {
       
   120  *  // check the condition of aReason here if needed
       
   121  *  if ( MCCAObserver::EExitEvent == aType )
       
   122  *      {
       
   123  *      // Calling Close() for iConnection will close the running 
       
   124  *      // CCApplication, so be careful when using it
       
   125  *      if ( iConnection )
       
   126  *          {
       
   127  *          iConnection->Close();
       
   128  *          iConnection = NULL;
       
   129  *          }
       
   130  *      }
       
   131  *  }
       
   132  *  ...
       
   133  *
       
   134  *  @endcode
       
   135  *
       
   136  *  @lib ccaclient
       
   137  *  @since S60 v5.0
       
   138  */
       
   139 class MCCAConnection
       
   140     {
       
   141 
       
   142 public:
       
   143 
       
   144     /**
       
   145      * Destroy this entity
       
   146      *
       
   147      * @since S60 5.0
       
   148      */
       
   149     virtual void Close() = 0;
       
   150 
       
   151     /**
       
   152      * DEPRECATED - USE LaunchAppL() instead!
       
   153      * Ownership of MCCAParameter is NOT transferred.
       
   154      */
       
   155     virtual void LaunchApplicationL( MCCAParameter& aParameter ) = 0;
       
   156 
       
   157     /**
       
   158      * Launches CCA application with the given parameter.
       
   159      * See above for example instructions.
       
   160      *
       
   161      * Ownership of MCCAParameter is transferred.
       
   162      *
       
   163      * Leaves KErrArgument if there is no contact data in the
       
   164      *        given parameter. 
       
   165      * Leaves KErrAlreadyExists if there is already CCApplication
       
   166      * running simultaneously.
       
   167      * 
       
   168      * @see MCCAParameter::SetContactDataL      
       
   169      * @since S60 5.0
       
   170      * @param aParameter to launch application
       
   171      * @param aObserver to get notifications (see MCCAObserver)
       
   172      */    
       
   173     virtual void LaunchAppL( 
       
   174         MCCAParameter& aParameter, 
       
   175         MCCAObserver* aObserver = NULL ) = 0;
       
   176     };
       
   177 
       
   178 #endif //M_MCCACONNECTION_H
       
   179 // End of File