btobexprofiles/obexserviceman/obexservicemanclient/src/ObexSMPlugin.cpp
branchRCL_3
changeset 56 9386f31cc85b
parent 55 613943a21004
child 61 269724087bed
equal deleted inserted replaced
55:613943a21004 56:9386f31cc85b
     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:  This is the ObexServiceManager ecom plugin class implementation.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "ObexSMPlugin.h"
       
    20 #include "ObexSMRequester.h"
       
    21 #include "debug.h"
       
    22 
       
    23 // ---------------------------------------------------------------------------
       
    24 // NewL
       
    25 // ---------------------------------------------------------------------------
       
    26 CObexSMPlugin* CObexSMPlugin::NewL(TLocodServicePluginParams& aParams)
       
    27     {
       
    28     TRACE_FUNC
       
    29     CObexSMPlugin* self = new (ELeave) CObexSMPlugin(aParams);
       
    30     CleanupStack::PushL(self);
       
    31     self->ConstructL();
       
    32     CleanupStack::Pop();
       
    33     return self;
       
    34     }
       
    35 
       
    36 // ---------------------------------------------------------------------------
       
    37 // Destructor
       
    38 // ---------------------------------------------------------------------------
       
    39 CObexSMPlugin::~CObexSMPlugin()
       
    40     {
       
    41     TRACE_FUNC_ENTRY      
       
    42     iRequests.ResetAndDestroy();
       
    43     iRequests.Close();    
       
    44     if(iObexSMServer.Handle())
       
    45         {              
       
    46         iObexSMServer.Close();       
       
    47         }    
       
    48     TRACE_FUNC_EXIT
       
    49     }
       
    50 
       
    51 // ---------------------------------------------------------------------------
       
    52 // ManageService
       
    53 // ---------------------------------------------------------------------------
       
    54 //
       
    55 void CObexSMPlugin::ManageService(TLocodBearer aBearer, TBool aStatus)
       
    56     {
       
    57     TRACE_FUNC_ENTRY    
       
    58     TInt err = KErrNone; 
       
    59     CObexSMRequester* request=NULL;
       
    60     
       
    61     if(!iObexSMServer.Handle())
       
    62     	{
       
    63        	err = iObexSMServer.Connect();              	
       
    64     	}    
       
    65     if(err == KErrNone &&  aBearer != ELocodBearerUSB)
       
    66     	{    	
       
    67     	TRAP(err, request = CObexSMRequester::NewL(this, aBearer, aStatus)); 
       
    68     	if(err==KErrNone)
       
    69     	    {
       
    70             err=iRequests.Append( request );     
       
    71             if(err==KErrNone)
       
    72                 {
       
    73                 request->ActivateRequest();               
       
    74                 }
       
    75             }        
       
    76     	}    
       
    77     else if(err == KErrNone &&  aBearer == ELocodBearerUSB) 	
       
    78         {
       
    79         Observer().ManageServiceCompleted(aBearer,aStatus,ImplementationUid(), KErrNone); 	           
       
    80         }
       
    81         
       
    82     if(err!=KErrNone)
       
    83         {
       
    84         Observer().ManageServiceCompleted(aBearer,aStatus,ImplementationUid(), err); 	       
       
    85         }
       
    86     TRACE_FUNC_EXIT    
       
    87     }
       
    88    
       
    89 // ---------------------------------------------------------------------------
       
    90 // Constructor
       
    91 // ---------------------------------------------------------------------------
       
    92 //
       
    93 
       
    94 CObexSMPlugin::CObexSMPlugin(TLocodServicePluginParams& aParams)
       
    95     : CLocodServicePlugin(aParams)
       
    96     {	        
       
    97 	}
       
    98 
       
    99 // ---------------------------------------------------------------------------
       
   100 // ConstructL
       
   101 // ---------------------------------------------------------------------------
       
   102 //
       
   103 void CObexSMPlugin::ConstructL()
       
   104     {    
       
   105     TRACE_FUNC    
       
   106     }
       
   107 
       
   108 // ---------------------------------------------------------------------------
       
   109 // RequestComplete
       
   110 // ---------------------------------------------------------------------------
       
   111 //
       
   112 void CObexSMPlugin::RequestComplete(CObexSMRequester* aRequest, TInt aError)
       
   113     {   
       
   114     TRACE_FUNC_ENTRY    
       
   115     
       
   116     TLocodBearer bearer= aRequest->GetBearer();
       
   117     TBool status = aRequest->GetStatus();       
       
   118     for(TInt index=0; index<iRequests.Count();index++)
       
   119         {        
       
   120         if(aRequest==iRequests[index])
       
   121             {
       
   122             delete iRequests[index];    
       
   123             iRequests.Remove(index);
       
   124             iRequests.Compress();
       
   125             break;
       
   126             }
       
   127         }         
       
   128     Observer().ManageServiceCompleted(bearer,status,ImplementationUid(), aError); 	   
       
   129     
       
   130     TRACE_FUNC_EXIT
       
   131     }      
       
   132 
       
   133 
       
   134 // ---------------------------------------------------------------------------
       
   135 // GetServer
       
   136 // ---------------------------------------------------------------------------
       
   137 //
       
   138 RObexSMServer&  CObexSMPlugin::GetServer()
       
   139     {
       
   140     TRACE_FUNC    
       
   141     return  iObexSMServer;
       
   142     }
       
   143     
       
   144 // End of file