presencefwsimpleadpt/src/simpleplugin.cpp
changeset 0 c8caa15ef882
equal deleted inserted replaced
-1:000000000000 0:c8caa15ef882
       
     1 /*
       
     2 * Copyright (c) 2006 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:    SIMPLE Protocol implementation for Presence Framework
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 #include <ecom/implementationproxy.h>
       
    22 
       
    23 #include <ximpserviceinfo.h>
       
    24 #include <ximpbase.h>
       
    25 #include <ximpidentity.h>
       
    26 #include <presenceinfo.h>
       
    27 #include <ximpprotocolconnectionhost.h>
       
    28 
       
    29 #include "simpleplugin.h"
       
    30 #include "simpleplugindef.h"
       
    31 #include "simplepluginconnection.h"
       
    32 
       
    33 
       
    34 
       
    35 // ======== MEMBER FUNCTIONS ========
       
    36 
       
    37 
       
    38 // ---------------------------------------------------------------------------
       
    39 // Key value pair table to identify correct constructor
       
    40 // function for the requested interface.
       
    41 // ---------------------------------------------------------------------------
       
    42 //
       
    43 const TImplementationProxy ImplementationTable[] =
       
    44     {
       
    45     IMPLEMENTATION_PROXY_ENTRY( K_SIMPLEPLUGIN_1_IMPLEMENTATION_UID, CSimplePlugin::NewL )
       
    46     };
       
    47 
       
    48 // ---------------------------------------------------------------------------
       
    49 // Exported function to return the implementation proxy table
       
    50 // ---------------------------------------------------------------------------
       
    51 //
       
    52 EXPORT_C const TImplementationProxy* ImplementationGroupProxy( TInt& aTableCount )
       
    53     {
       
    54     aTableCount = sizeof( ImplementationTable ) / sizeof( TImplementationProxy );
       
    55     return ImplementationTable;
       
    56     }
       
    57 
       
    58 // ---------------------------------------------------------------------------
       
    59 // CSimplePlugin::CSimplePlugin()
       
    60 // ---------------------------------------------------------------------------
       
    61 //
       
    62 CSimplePlugin::CSimplePlugin()
       
    63     {
       
    64     }
       
    65 
       
    66 // ---------------------------------------------------------------------------
       
    67 // CSimplePlugin::ConstructL()
       
    68 // ---------------------------------------------------------------------------
       
    69 //
       
    70 void CSimplePlugin::ConstructL()
       
    71     {
       
    72     }
       
    73 
       
    74 // ---------------------------------------------------------------------------
       
    75 // CSimplePlugin::NewLC()
       
    76 // ---------------------------------------------------------------------------
       
    77 //
       
    78 CSimplePlugin* CSimplePlugin::NewLC()
       
    79     {
       
    80     CSimplePlugin* self = new( ELeave ) CSimplePlugin();
       
    81     CleanupStack::PushL( self );
       
    82     self->ConstructL();
       
    83     return self;
       
    84     }
       
    85 
       
    86 // ---------------------------------------------------------------------------
       
    87 // CSimplePlugin::NewL()
       
    88 // ---------------------------------------------------------------------------
       
    89 //
       
    90 CSimplePlugin* CSimplePlugin::NewL()
       
    91     {
       
    92     CSimplePlugin* self = CSimplePlugin::NewLC();
       
    93     CleanupStack::Pop( self );
       
    94     return self;
       
    95     }
       
    96 
       
    97 // ---------------------------------------------------------------------------
       
    98 // CSimplePlugin::~CSimplePlugin()
       
    99 // ---------------------------------------------------------------------------
       
   100 //
       
   101 CSimplePlugin::~CSimplePlugin()
       
   102     {
       
   103     iConnections.ResetAndDestroy();
       
   104     }
       
   105 
       
   106 // ---------------------------------------------------------------------------
       
   107 // CSimplePlugin::PrimeHost()
       
   108 // ---------------------------------------------------------------------------
       
   109 //
       
   110 void CSimplePlugin::PrimeHost( MXIMPProtocolPluginHost& aHost )
       
   111     {
       
   112     iHost = &aHost;
       
   113     }
       
   114 
       
   115 // ---------------------------------------------------------------------------
       
   116 // CSimplePlugin::AcquireConnectionL()
       
   117 // ---------------------------------------------------------------------------
       
   118 //
       
   119 MXIMPProtocolConnection& CSimplePlugin::AcquireConnectionL(
       
   120     const MXIMPServiceInfo& aServiceInfo,
       
   121     const MXIMPContextClientInfo& aContextClient )
       
   122     {
       
   123     
       
   124     // TODO: singleton takes place here. Change name to CSimplePluginImp???
       
   125     // CSimplePluginConnection reflects to Singleton. This should compare PresenceID
       
   126     // and share a single entity with identical ids.HOW DOES PrFW work in this case???
       
   127 
       
   128     // support multiple connections
       
   129     // always create a new connection - no connection sharing, it takes place in SIP Stack.
       
   130     CSimplePluginConnection* connection =
       
   131         CSimplePluginConnection::NewL( aServiceInfo, aContextClient );
       
   132     CleanupStack::PushL( connection );
       
   133     iConnections.AppendL( connection );
       
   134     CleanupStack::Pop( connection );
       
   135     return *connection;
       
   136     }
       
   137 
       
   138 // ---------------------------------------------------------------------------
       
   139 // CSimplePlugin::ReleaseConnection()
       
   140 // ---------------------------------------------------------------------------
       
   141 //
       
   142 void CSimplePlugin::ReleaseConnection( MXIMPProtocolConnection& aConnection )
       
   143     {
       
   144     TInt connectionsCount = iConnections.Count();
       
   145 
       
   146     for( TInt i( connectionsCount - 1 ); i >= 0; i-- )
       
   147         {
       
   148         MXIMPProtocolConnection* tmp = iConnections[i];
       
   149         if( tmp == &aConnection )
       
   150             {
       
   151             delete iConnections[i];
       
   152             iConnections.Remove( i );
       
   153             }
       
   154         }
       
   155     }
       
   156 
       
   157 // ---------------------------------------------------------------------------
       
   158 // CSimplePlugin::GetInterface()
       
   159 // ---------------------------------------------------------------------------
       
   160 //
       
   161 TAny* CSimplePlugin::GetInterface(
       
   162     TInt32 aInterfaceId,
       
   163     TIfGetOps aOptions )
       
   164     {
       
   165 
       
   166     if ( aInterfaceId == GetInterfaceId() )
       
   167         {
       
   168         // caller wants this interface
       
   169         MXIMPProtocolPlugin* myIf = this;
       
   170         return myIf;
       
   171         }
       
   172     if( aOptions == MXIMPBase::EPanicIfUnknown )
       
   173         {
       
   174         User::Panic( _L("CSimplePlugin"), KErrExtensionNotSupported );
       
   175         }
       
   176     return NULL;
       
   177     }
       
   178 
       
   179 // ---------------------------------------------------------------------------
       
   180 // CSimplePlugin::GetInterface()
       
   181 // ---------------------------------------------------------------------------
       
   182 //
       
   183 const TAny* CSimplePlugin::GetInterface(
       
   184     TInt32 aInterfaceId,
       
   185     TIfGetOps aOptions ) const
       
   186     {
       
   187     if ( aInterfaceId == GetInterfaceId() )
       
   188         {
       
   189         // caller wants this interface
       
   190         const MXIMPProtocolPlugin* myIf = this;
       
   191         return myIf;
       
   192         }
       
   193     if( aOptions == MXIMPBase::EPanicIfUnknown )
       
   194         {
       
   195         User::Panic( _L("CSimplePlugin"), KErrExtensionNotSupported );
       
   196         }
       
   197     return NULL;
       
   198     }
       
   199 
       
   200 // ---------------------------------------------------------------------------
       
   201 // CSimplePlugin::GetInterfaceId()
       
   202 // ---------------------------------------------------------------------------
       
   203 //
       
   204 TInt32 CSimplePlugin::GetInterfaceId() const
       
   205     {
       
   206     return MXIMPProtocolPlugin::KInterfaceId;
       
   207     }
       
   208     
       
   209     
       
   210 
       
   211 
       
   212 
       
   213 // End of file
       
   214