mtpfws/mtpfw/src/cmtpservicemgr.cpp
changeset 49 c20dd21d1eb4
parent 0 d0791faffa3f
equal deleted inserted replaced
41:2c19c7cf5550 49:c20dd21d1eb4
    21 
    21 
    22 #include "mtpservicecommon.h"
    22 #include "mtpservicecommon.h"
    23 #include "cmtpserviceconfig.h"
    23 #include "cmtpserviceconfig.h"
    24 #include "cmtpservicemgr.h"
    24 #include "cmtpservicemgr.h"
    25 #include <mtp/mtpprotocolconstants.h>
    25 #include <mtp/mtpprotocolconstants.h>
    26 
    26 #include "OstTraceDefinitions.h"
    27 __FLOG_STMT(_LIT8(KComponent,"ServiceMgr");)
    27 #ifdef OST_TRACE_COMPILER_IN_USE
       
    28 #include "cmtpservicemgrTraces.h"
       
    29 #endif
       
    30 
    28 
    31 
    29 
    32 
    30 /**
    33 /**
    31 
    34 
    32 */
    35 */
    44     
    47     
    45     }
    48     }
    46 
    49 
    47 void CMTPServiceMgr::ConstructL()
    50 void CMTPServiceMgr::ConstructL()
    48 	{
    51 	{
    49 	__FLOG_OPEN(KMTPSubsystem, KComponent);
    52 	OstTraceFunctionEntry0( CMTPSERVICEMGR_CONSTRUCTL_ENTRY );
    50 	__FLOG(_L8("ConstructL - Entry"));
       
    51 	
    53 	
    52     iSingletons.OpenL();
    54     iSingletons.OpenL();
    53 	iServiceCfg = CMTPServiceConfig::NewL( iSingletons.Fs() );
    55 	iServiceCfg = CMTPServiceConfig::NewL( iSingletons.Fs() );
    54 	   
    56 
    55 	__FLOG(_L8("ConstructL - Exit"));
    57 	OstTraceFunctionExit0( CMTPSERVICEMGR_CONSTRUCTL_EXIT );
    56 	}
    58 	}
    57 /**
    59 /**
    58 Destructor
    60 Destructor
    59 */    
    61 */    
    60 CMTPServiceMgr::~CMTPServiceMgr()
    62 CMTPServiceMgr::~CMTPServiceMgr()
    61     {
    63     {
    62     __FLOG(_L8("~CMTPServiceMgr - Entry"));
    64     OstTraceFunctionEntry0( CMTPSERVICEMGR_CMTPSERVICEMGR_DES_ENTRY );
    63     
    65     
    64     delete iServiceCfg;
    66     delete iServiceCfg;
    65     
    67     
    66     iSingletons.Close();
    68     iSingletons.Close();
    67     
    69     
    68     iServiceIDs.Close();
    70     iServiceIDs.Close();
    69     
    71 
    70     __FLOG(_L8("~CMTPServiceMgr - Exit"));
    72     OstTraceFunctionExit0( CMTPSERVICEMGR_CMTPSERVICEMGR_DES_EXIT );
    71     __FLOG_CLOSE;
       
    72     }
    73     }
    73 
    74 
    74 EXPORT_C TBool CMTPServiceMgr::IsSupportedService( const TUint aServiceID ) const
    75 EXPORT_C TBool CMTPServiceMgr::IsSupportedService( const TUint aServiceID ) const
    75     {
    76     {
    76     return ( ServiceInfo( aServiceID ) != NULL );
    77     return ( ServiceInfo( aServiceID ) != NULL );
    81     return iServiceCfg->IsSupportedService( aPGUID );
    82     return iServiceCfg->IsSupportedService( aPGUID );
    82     }
    83     }
    83 
    84 
    84 TInt CMTPServiceMgr::EnableService(const TMTPTypeGuid& aPGUID, const TUint aServiceID )
    85 TInt CMTPServiceMgr::EnableService(const TMTPTypeGuid& aPGUID, const TUint aServiceID )
    85     {
    86     {
    86     __FLOG(_L8("CMTPServiceMgr::EnableService : "));
    87     OstTraceFunctionEntry0( CMTPSERVICEMGR_ENABLESERVICE_ENTRY );
    87     
    88     
    88     if( NULL == iServiceCfg->ServiceInfo(aPGUID)  )
    89     if( NULL == iServiceCfg->ServiceInfo(aPGUID)  )
    89         {
    90         {
    90         TRAPD(err,LoadServiceL( aPGUID ));
    91         TRAPD(err,LoadServiceL( aPGUID ));
    91         if( KErrNone == err)
    92         if( KErrNone == err)
    92             {
    93             {
    93             iServiceCfg->ServiceInfo(aPGUID)->SetServiceID( aServiceID );
    94             iServiceCfg->ServiceInfo(aPGUID)->SetServiceID( aServiceID );
    94             }
    95             }
    95         
    96         else
    96         __FLOG_1(_L8("CMTPServiceMgr::EnableService - Fail to Load service! error = %d "), err );
    97             OstTraceDef1(OST_TRACE_CATEGORY_PRODUCTION, TRACE_IMPORTANT, CMTPSERVICEMGR_ENABLESERVICE, 
       
    98                     "CMTPServiceMgr::EnableService - Fail to Load service! error = %d", err);
       
    99         OstTraceFunctionExit0( CMTPSERVICEMGR_ENABLESERVICE_EXIT );
    97         return err;
   100         return err;
    98         }
   101         }
    99     
   102     
   100     __FLOG(_L8("CMTPServiceMgr::EnableService - Has been loaded!"));
   103     OstTrace0(TRACE_NORMAL, DUP1_CMTPSERVICEMGR_ENABLESERVICE, "CMTPServiceMgr::EnableService - Has been loaded!");
   101     
   104     OstTraceFunctionExit0( DUP1_CMTPSERVICEMGR_ENABLESERVICE_EXIT );
   102     return KErrNone;
   105     return KErrNone;
   103     }
   106     }
   104 
   107 
   105 TInt CMTPServiceMgr::ServiceTypeOfSupportedService( const TMTPTypeGuid& aPGUID ) const
   108 TInt CMTPServiceMgr::ServiceTypeOfSupportedService( const TMTPTypeGuid& aPGUID ) const
   106     {
   109     {
   132     return iServiceIDs.InsertInOrder( aServiceId );
   135     return iServiceIDs.InsertInOrder( aServiceId );
   133     }
   136     }
   134 
   137 
   135 void CMTPServiceMgr::LoadServiceL( const TMTPTypeGuid& aPGUID )
   138 void CMTPServiceMgr::LoadServiceL( const TMTPTypeGuid& aPGUID )
   136 	{
   139 	{
   137 	__FLOG(_L8("CMTPServiceMgr::LoadServiceL - Entry"));
   140 	OstTraceFunctionEntry0( CMTPSERVICEMGR_LOADSERVICEL_ENTRY );
   138 
   141 
   139 	iServiceCfg->LoadServiceDataL(aPGUID);
   142 	iServiceCfg->LoadServiceDataL(aPGUID);
   140 	
   143 
   141     __FLOG(_L8("CMTPServiceMgr::LoadServiceL - Exit"));
   144 	OstTraceFunctionExit0( CMTPSERVICEMGR_LOADSERVICEL_EXIT );
   142 	}
   145 	}
   143 
   146 
   144 TInt CMTPServiceMgr::GetServiceProperty( const TMTPTypeGuid& aServicePGUID, const TMTPTypeGuid& aPKNamespace, const TUint aPKID, CServiceProperty** aServicePropertye) const
   147 TInt CMTPServiceMgr::GetServiceProperty( const TMTPTypeGuid& aServicePGUID, const TMTPTypeGuid& aPKNamespace, const TUint aPKID, CServiceProperty** aServicePropertye) const
   145     {
   148     {
   146     __FLOG(_L8("CMTPServiceMgr::GetServiceProperty :"));
   149     OstTraceFunctionEntry0( CMTPSERVICEMGR_GETSERVICEPROPERTY_ENTRY );
   147         
   150 
   148     CMTPServiceInfo* svcinfo = iServiceCfg->ServiceInfo( aServicePGUID );
   151     CMTPServiceInfo* svcinfo = iServiceCfg->ServiceInfo( aServicePGUID );
   149     if( NULL == svcinfo )
   152     if( NULL == svcinfo )
   150        return KErrNotSupported;
   153        return KErrNotSupported;
   151     
   154     
   152     CServiceProperty* prop = svcinfo->ServiceProperty( aPKNamespace, aPKID );
   155     CServiceProperty* prop = svcinfo->ServiceProperty( aPKNamespace, aPKID );
   153     if( NULL == prop)
   156     if( NULL == prop)
   154        return KErrNotSupported;
   157        return KErrNotSupported;
   155     
   158     
   156     *aServicePropertye = prop;
   159     *aServicePropertye = prop;
   157     
   160 
   158     __FLOG(_L8("CMTPServiceMgr::GetServiceProperty Exit"));
   161     OstTraceFunctionExit0( CMTPSERVICEMGR_GETSERVICEPROPERTY_EXIT );
   159     return KErrNone;
   162     return KErrNone;
   160     }
   163     }
   161 
   164 
   162 TInt CMTPServiceMgr::GetServiceFormat( const TMTPTypeGuid& aServicePGUID, const TMTPTypeGuid& aGUID, CServiceFormat** aServiceFormat ) const
   165 TInt CMTPServiceMgr::GetServiceFormat( const TMTPTypeGuid& aServicePGUID, const TMTPTypeGuid& aGUID, CServiceFormat** aServiceFormat ) const
   163    {
   166    {
   164     __FLOG(_L8("CMTPServiceMgr::GetServiceFormat :"));
   167     OstTraceFunctionEntry0( CMTPSERVICEMGR_GETSERVICEFORMAT_ENTRY );
   165     
   168 
   166     CMTPServiceInfo* svcinfo = iServiceCfg->ServiceInfo( aServicePGUID );
   169     CMTPServiceInfo* svcinfo = iServiceCfg->ServiceInfo( aServicePGUID );
   167     if( NULL == svcinfo )
   170     if( NULL == svcinfo )
   168        return KErrNotSupported;
   171        return KErrNotSupported;
   169     
   172     
   170     CServiceFormat* format = svcinfo->ServiceFormat( aGUID );
   173     CServiceFormat* format = svcinfo->ServiceFormat( aGUID );
   171     if( NULL == format)
   174     if( NULL == format)
   172        return KErrNotSupported;
   175        return KErrNotSupported;
   173     
   176     
   174     *aServiceFormat = format;
   177     *aServiceFormat = format;
   175    
   178 
   176     __FLOG(_L8("CMTPServiceMgr::GetServiceFormat Exit"));
   179     OstTraceFunctionExit0( CMTPSERVICEMGR_GETSERVICEFORMAT_EXIT );
   177     return KErrNone;
   180     return KErrNone;
   178    }
   181    }
   179 
   182 
   180 TInt CMTPServiceMgr::GetServiceMethod( const TMTPTypeGuid& aServicePGUID, const TMTPTypeGuid& aGUID, CServiceMethod** aServiceMethod ) const
   183 TInt CMTPServiceMgr::GetServiceMethod( const TMTPTypeGuid& aServicePGUID, const TMTPTypeGuid& aGUID, CServiceMethod** aServiceMethod ) const
   181    {
   184    {
   182     __FLOG(_L8("CMTPServiceMgr::GetServiceMethod :"));
   185     OstTraceFunctionEntry0( CMTPSERVICEMGR_GETSERVICEMETHOD_ENTRY );
   183     
   186     
   184     CMTPServiceInfo* svcinfo = iServiceCfg->ServiceInfo( aServicePGUID );
   187     CMTPServiceInfo* svcinfo = iServiceCfg->ServiceInfo( aServicePGUID );
   185     if( NULL == svcinfo )
   188     if( NULL == svcinfo )
   186        return KErrNotSupported;
   189        return KErrNotSupported;
   187     
   190     
   189     if( NULL == method)
   192     if( NULL == method)
   190        return KErrNotSupported;
   193        return KErrNotSupported;
   191     
   194     
   192     *aServiceMethod = method ;
   195     *aServiceMethod = method ;
   193     
   196     
   194     __FLOG(_L8("CMTPServiceMgr::GetServiceMethod - Exit"));
   197     OstTraceFunctionExit0( CMTPSERVICEMGR_GETSERVICEMETHOD_EXIT );
   195     return KErrNone;
   198     return KErrNone;
   196    }
   199    }
   197 
   200 
   198 TInt CMTPServiceMgr::GetServiceId( const TMTPTypeGuid& aServiceGUID, TUint& aServiceID) const
   201 TInt CMTPServiceMgr::GetServiceId( const TMTPTypeGuid& aServiceGUID, TUint& aServiceID) const
   199 	{
   202 	{
   200 	__FLOG(_L8("CMTPServiceMgr::FindServiceId :"));
   203 	OstTraceFunctionEntry0( CMTPSERVICEMGR_GETSERVICEID_ENTRY );
   201 	
   204 	
   202 	CMTPServiceInfo* svcinfo = ServiceInfo( aServiceGUID );
   205 	CMTPServiceInfo* svcinfo = ServiceInfo( aServiceGUID );
   203 	
   206 	
   204 	if( NULL ==  svcinfo )
   207 	if( NULL ==  svcinfo )
   205 	    {
   208 	    {
   206 	    __FLOG(_L8("CMTPServiceMgr::GetServiceId - Invalid serviceID"));
   209 	    OstTrace0(TRACE_ERROR, CMTPSERVICEMGR_GETSERVICEID, "CMTPServiceMgr::GetServiceId - Invalid serviceID");   
   207 	    
   210 	    OstTraceFunctionExit0( CMTPSERVICEMGR_GETSERVICEID_EXIT );
   208 	    return KErrNotFound;
   211 	    return KErrNotFound;
   209 	    }
   212 	    }
   210 	else
   213 	else
   211 	    {
   214 	    {
   212 	    aServiceID = svcinfo->ServiceID();
   215 	    aServiceID = svcinfo->ServiceID();
   213 	    
   216 	    
   214 	    __FLOG_1(_L8("CMTPServiceMgr::GetServiceId = %d"),aServiceID );
   217 	    OstTrace1(TRACE_NORMAL, DUP1_CMTPSERVICEMGR_GETSERVICEID, 
   215 	    
   218 	            "CMTPServiceMgr::GetServiceId = %d", aServiceID);
       
   219 	    OstTraceFunctionExit0( DUP1_CMTPSERVICEMGR_GETSERVICEID_EXIT );
   216 	    return KErrNone;
   220 	    return KErrNone;
   217 	    }
   221 	    }
   218 	}
   222 	}
   219 
   223 
   220 TInt CMTPServiceMgr::GetServicePropertyCode( const TMTPTypeGuid& aServicePGUID, const TMTPTypeGuid& aPKNamespace, const TUint aPKID, TUint& aServicePropertyCode ) const
   224 TInt CMTPServiceMgr::GetServicePropertyCode( const TMTPTypeGuid& aServicePGUID, const TMTPTypeGuid& aPKNamespace, const TUint aPKID, TUint& aServicePropertyCode ) const
   221     {
   225     {
   222     __FLOG(_L8("CMTPServiceMgr::GetServicePropertyCode :"));
   226     OstTraceFunctionEntry0( CMTPSERVICEMGR_GETSERVICEPROPERTYCODE_ENTRY );
   223     
   227     
   224     CServiceProperty* prop = NULL;
   228     CServiceProperty* prop = NULL;
   225     TInt err =  GetServiceProperty( aServicePGUID, aPKNamespace, aPKID, &prop );
   229     TInt err =  GetServiceProperty( aServicePGUID, aPKNamespace, aPKID, &prop );
   226     if( KErrNone != err)
   230     if( KErrNone != err)
   227         return err;
   231         return err;
   228     
   232     
   229     aServicePropertyCode = prop->Code();
   233     aServicePropertyCode = prop->Code();
   230  
   234 
   231     __FLOG(_L8("CMTPServiceMgr::GetServicePropertyCode - Exit"));
   235     OstTraceFunctionExit0( CMTPSERVICEMGR_GETSERVICEPROPERTYCODE_EXIT );
   232     return KErrNone;
   236     return KErrNone;
   233     }
   237     }
   234 
   238 
   235 TInt CMTPServiceMgr::SetServicePropertyCode( const TMTPTypeGuid& aServicePGUID, const TMTPTypeGuid& aPKNamespace, const TUint aPKID, const TUint aCurrPropertyCode )
   239 TInt CMTPServiceMgr::SetServicePropertyCode( const TMTPTypeGuid& aServicePGUID, const TMTPTypeGuid& aPKNamespace, const TUint aPKID, const TUint aCurrPropertyCode )
   236     {
   240     {
   237     __FLOG(_L8("CMTPServiceMgr::SetServicePropertyCode :"));
   241     OstTraceFunctionEntry0( CMTPSERVICEMGR_SETSERVICEPROPERTYCODE_ENTRY );
   238     
   242     
   239     CServiceProperty* prop = NULL;
   243     CServiceProperty* prop = NULL;
   240     TInt err =  GetServiceProperty( aServicePGUID, aPKNamespace, aPKID, &prop );
   244     TInt err =  GetServiceProperty( aServicePGUID, aPKNamespace, aPKID, &prop );
   241     if( KErrNone != err)
   245     if( KErrNone != err)
   242         return err;
   246         return err;
   243     
   247     
   244     prop->SetCode( aCurrPropertyCode );
   248     prop->SetCode( aCurrPropertyCode );
   245     
   249     
   246     __FLOG(_L8("CMTPServiceMgr::SetServicePropertyCode - Exit"));
   250     OstTraceFunctionExit0( CMTPSERVICEMGR_SETSERVICEPROPERTYCODE_EXIT );
   247     return KErrNone;
   251     return KErrNone;
   248     }
   252     }
   249 
   253 
   250 TInt CMTPServiceMgr::GetServiceFormatCode( const TMTPTypeGuid& aServicePGUID, const TMTPTypeGuid& aGUID, TUint& aServiceFormatCode ) const
   254 TInt CMTPServiceMgr::GetServiceFormatCode( const TMTPTypeGuid& aServicePGUID, const TMTPTypeGuid& aGUID, TUint& aServiceFormatCode ) const
   251     {
   255     {
   252     __FLOG(_L8("CMTPServiceMgr::GetServiceFormatCode :"));
   256     OstTraceFunctionEntry0( CMTPSERVICEMGR_GETSERVICEFORMATCODE_ENTRY );
   253     
   257 
   254     CServiceFormat* format = NULL;
   258     CServiceFormat* format = NULL;
   255     TInt err = GetServiceFormat( aServicePGUID, aGUID, &format );
   259     TInt err = GetServiceFormat( aServicePGUID, aGUID, &format );
   256     if( KErrNone != err )
   260     if( KErrNone != err )
   257         return err;
   261         return err;
   258     
   262     
   259     aServiceFormatCode = format->Code();
   263     aServiceFormatCode = format->Code();
   260     
   264 
   261     __FLOG(_L8("CMTPServiceMgr::GetServiceFormatCode - Exit"));
   265     OstTraceFunctionExit0( CMTPSERVICEMGR_GETSERVICEFORMATCODE_EXIT );
   262     return KErrNone;
   266     return KErrNone;
   263     }
   267     }
   264 
   268 
   265 TInt CMTPServiceMgr::SetServiceFormatCode( const TMTPTypeGuid& aServicePGUID, const TMTPTypeGuid& aGUID, const TUint aCurrFormatCode )
   269 TInt CMTPServiceMgr::SetServiceFormatCode( const TMTPTypeGuid& aServicePGUID, const TMTPTypeGuid& aGUID, const TUint aCurrFormatCode )
   266     {
   270     {
   267     __FLOG(_L8("CMTPServiceMgr::SetServiceFormatCode :"));
   271     OstTraceFunctionEntry0( CMTPSERVICEMGR_SETSERVICEFORMATCODE_ENTRY );
   268     
   272 
   269     CServiceFormat* format = NULL;
   273     CServiceFormat* format = NULL;
   270     TInt err = GetServiceFormat( aServicePGUID, aGUID, &format );
   274     TInt err = GetServiceFormat( aServicePGUID, aGUID, &format );
   271     if( KErrNone != err )
   275     if( KErrNone != err )
   272        return err;
   276        return err;
   273     
   277     
   274     format->SetCode( aCurrFormatCode );
   278     format->SetCode( aCurrFormatCode );
   275     
   279 
   276     __FLOG(_L8("CMTPServiceMgr::SetServiceFormatCode - Exit"));
   280     OstTraceFunctionExit0( CMTPSERVICEMGR_SETSERVICEFORMATCODE_EXIT );
   277     return KErrNone;
   281     return KErrNone;
   278     }
   282     }
   279 
   283 
   280 TInt CMTPServiceMgr::GetServiceMethodCode( const TMTPTypeGuid& aServicePGUID, const TMTPTypeGuid& aGUID, TUint& aServiceMethodCode ) const
   284 TInt CMTPServiceMgr::GetServiceMethodCode( const TMTPTypeGuid& aServicePGUID, const TMTPTypeGuid& aGUID, TUint& aServiceMethodCode ) const
   281     {
   285     {
   282     __FLOG(_L8("CMTPServiceMgr::GetServiceMethodCode :"));
   286     OstTraceFunctionEntry0( CMTPSERVICEMGR_GETSERVICEMETHODCODE_ENTRY );
   283     
   287 
   284     CServiceMethod* method = NULL;
   288     CServiceMethod* method = NULL;
   285     TInt err = GetServiceMethod( aServicePGUID, aGUID, &method );
   289     TInt err = GetServiceMethod( aServicePGUID, aGUID, &method );
   286     if ( KErrNone != err )
   290     if ( KErrNone != err )
   287         return err;
   291         return err;
   288     
   292     
   289     aServiceMethodCode = method->Code();
   293     aServiceMethodCode = method->Code();
   290     
   294 
   291     __FLOG(_L8("CMTPServiceMgr::GetServiceMethodCode - Exit"));
   295     OstTraceFunctionExit0( CMTPSERVICEMGR_GETSERVICEMETHODCODE_EXIT );
   292     return KErrNone;
   296     return KErrNone;
   293     }
   297     }
   294 
   298 
   295 TInt CMTPServiceMgr::SetServiceMethodCode( const TMTPTypeGuid& aServicePGUID, const TMTPTypeGuid& aGUID, const TUint aCurrMethodCode )
   299 TInt CMTPServiceMgr::SetServiceMethodCode( const TMTPTypeGuid& aServicePGUID, const TMTPTypeGuid& aGUID, const TUint aCurrMethodCode )
   296     {
   300     {
   297     __FLOG(_L8("CMTPServiceMgr::SetServiceMethodCode :"));
   301     OstTraceFunctionEntry0( CMTPSERVICEMGR_SETSERVICEMETHODCODE_ENTRY );
   298     
   302     
   299     CServiceMethod* method = NULL;
   303     CServiceMethod* method = NULL;
   300     TInt err = GetServiceMethod( aServicePGUID, aGUID, &method );
   304     TInt err = GetServiceMethod( aServicePGUID, aGUID, &method );
   301     if ( KErrNone != err )
   305     if ( KErrNone != err )
   302         return err;
   306         return err;
   303     
   307     
   304     method->SetCode( aCurrMethodCode );
   308     method->SetCode( aCurrMethodCode );
   305     
   309     
   306     __FLOG(_L8("CMTPServiceMgr::SetServiceMethodCode - Exit"));
   310     OstTraceFunctionExit0( CMTPSERVICEMGR_SETSERVICEMETHODCODE_EXIT );
   307     return KErrNone;
   311     return KErrNone;
   308     }
   312     }
   309 
   313 
   310 
   314