telephonyserverplugins/common_tsy/phonetsy/src/cmmphonefactorytsy.cpp
changeset 0 3553901f7fa8
child 14 7ef16719d8cb
equal deleted inserted replaced
-1:000000000000 0:3553901f7fa8
       
     1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // INCLUDE FILES
       
    15 //
       
    16 
       
    17 
       
    18 
       
    19 #include <featmgr/featurecontrol.h>
       
    20 #include <featureuids.h>
       
    21 
       
    22 #include "cmmphonefactorytsy.h"
       
    23 #include "cmmphonetsy.h"
       
    24 #include <ctsy/mmtsy_names.h>
       
    25 #include "MmTsy_conf.h"
       
    26 #include "cmmmessagemanagerbase.h"
       
    27 #include <ctsy/serviceapi/ctsysatmessagingbase.h>
       
    28 
       
    29 #ifdef USING_CTSY_DISPATCHER
       
    30 _LIT(KLicenseeTsyDllName, "licenseetsy.dll");
       
    31 _LIT(KCtsyDispatcherDllName, "ctsydispatcher.dll");
       
    32 
       
    33 const TInt KLicenseeTsyUID3 = 0x2000BEE4;
       
    34 const TInt KCtsyDispatcherUID3 =  0x10285C38;
       
    35 
       
    36 typedef MLtsyFactoryBase*(*TFactoryBaseNewL)();
       
    37 
       
    38 #endif //USING_CTSY_DISPATCHER
       
    39 // ======== MEMBER FUNCTIONS ========
       
    40 
       
    41 CMmPhoneFactoryTsy::CMmPhoneFactoryTsy()
       
    42     {
       
    43     // Version numbers defined in ETEL.h
       
    44     iVersion = TVersion( KEtelMajorVersionNumber,
       
    45         KEtelMinorVersionNumber,
       
    46         KEtelBuildVersionNumber );
       
    47     }
       
    48 
       
    49 CMmPhoneFactoryTsy* CMmPhoneFactoryTsy::NewL()
       
    50     {
       
    51     CMmPhoneFactoryTsy* phoneFactoryTsy = NULL;
       
    52     phoneFactoryTsy = new ( ELeave ) CMmPhoneFactoryTsy();
       
    53     CleanupStack::PushL( phoneFactoryTsy );
       
    54     phoneFactoryTsy->ConstructL();   
       
    55     CleanupStack::Pop();
       
    56     return phoneFactoryTsy;
       
    57     }    
       
    58 
       
    59 void CMmPhoneFactoryTsy::ConstructL()
       
    60     {
       
    61     }
       
    62 
       
    63 CMmPhoneFactoryTsy::~CMmPhoneFactoryTsy()
       
    64     {
       
    65 #ifdef USING_CTSY_DISPATCHER
       
    66     iLoadedLib.Close();
       
    67 #endif //USING_CTSY_DISPATCHER
       
    68 	}
       
    69 
       
    70 // ---------------------------------------------------------------------------
       
    71 // CMmPhoneFactoryTsy::NewPhoneL
       
    72 // Creates a new phone object instance
       
    73 // (other items were commented in a header).
       
    74 // ---------------------------------------------------------------------------
       
    75 //
       
    76 CPhoneBase* CMmPhoneFactoryTsy::NewPhoneL( const TDesC& aName )
       
    77     {
       
    78 TFLOGSTRING("TSY: CMmPhoneFactoryTsy::NewL - NEW LOG");
       
    79 
       
    80     iPhoneTsy = NULL;
       
    81 
       
    82     // In case of debug build, print flag info.
       
    83 #ifdef TF_LOGGING_ENABLED
       
    84     
       
    85 	RFeatureControl featureControl;
       
    86 	TInt err = featureControl.Open();
       
    87 	if (err != KErrNone)
       
    88 		{
       
    89 TFLOGSTRING("CMmPhoneFactoryTsy::NewPhoneL - failed to connect to FeatMgr");
       
    90 		}
       
    91 	else if (featureControl.FeatureSupported(NFeature::KCsVideoTelephony) == KFeatureSupported) 
       
    92         {
       
    93 TFLOGSTRING("TSY: __CS_VIDEO_TELEPHONY -flag is on");
       
    94         }
       
    95 	else if (featureControl.FeatureSupported(NFeature::KEmergencyCallsEnabledInOfflineMode) == KFeatureSupported)
       
    96         {
       
    97 TFLOGSTRING("TSY: __COMMON_TSY__EMERGENCY_CALLS_ENABLED_IN_OFFLINE_MODE -flag is on");
       
    98         }
       
    99 
       
   100 	featureControl.Close();
       
   101 #endif
       
   102 	
       
   103     // Check if the Phone Name is OK
       
   104     if ( KErrNone == aName.CompareF( KMmTsyPhoneName ) )
       
   105         {
       
   106         iMessageRouter = NULL;
       
   107 
       
   108         // Create Message Manager (the 'core' of the LTSY Plug-in API)
       
   109         CMmMessageManagerBase* messageManager = CMmMessageManagerBase::NewL();
       
   110         if ( messageManager )
       
   111             {
       
   112 	        CleanupStack::PushL( messageManager );
       
   113         
       
   114             // LTSY Plug-in API successfully created
       
   115 TFLOGSTRING("TSY: CMmPhoneFactoryTsy::NewL - Starting to open LicenceeTSY");
       
   116             
       
   117             // get TSY message manager callback object
       
   118             MmMessageManagerCallback* callBack = 
       
   119                 messageManager->GetMessageManagerCallback();
       
   120             
       
   121 #ifdef USING_CTSY_DISPATCHER
       
   122             iLtsyFactory = LoadLibraryL();
       
   123 #else
       
   124             // library entry for LTSY, get base factory object
       
   125             iLtsyFactory = LTsyFactoryL();
       
   126             
       
   127 #endif //USING_CTSY_DISPATCHER
       
   128 
       
   129             if( iLtsyFactory )
       
   130                 {
       
   131                 // Get message router from LTSY. All current interface versions
       
   132                 // have the same GetMessageRouter defined in version 1.
       
   133                 MLtsyFactoryV1* ptr_v1 = 
       
   134                 	static_cast<MLtsyFactoryV1*>( iLtsyFactory );
       
   135                         
       
   136                 iMessageRouter = ptr_v1->GetMessageRouter( *callBack );
       
   137 		        User::LeaveIfNull( iMessageRouter );
       
   138         
       
   139 		        // Licencee Tsy successfully created
       
   140 TFLOGSTRING("TSY: CMmPhoneFactoryTsy::NewL -  LicenceeTSY successfully opened");
       
   141 
       
   142 	            // set the pointer to the message router object
       
   143 	            messageManager->SetMessageRouter( iMessageRouter );
       
   144 
       
   145 	            // Create Phone Tsy (which creates the whole Common TSY)
       
   146 TFLOGSTRING("TSY: CMmPhoneFactoryTsy::NewL - Starting to open CommonTSY");
       
   147 	            iPhoneTsy = CMmPhoneTsy::NewL( 
       
   148 	                messageManager, this, iLtsyFactory );
       
   149 
       
   150 	            if ( iPhoneTsy )
       
   151 	                {
       
   152 			        CleanupStack::Pop( messageManager );
       
   153 TFLOGSTRING("TSY: CMmPhoneFactoryTsy::NewL - CommonTSY successfully opened");
       
   154 	                messageManager->SetPhoneTsy( iPhoneTsy );
       
   155 	                }
       
   156 	            else
       
   157 	            	{
       
   158 			        CleanupStack::PopAndDestroy( messageManager );
       
   159 	            	}
       
   160                 }
       
   161             else
       
   162             	{
       
   163     	        CleanupStack::PopAndDestroy( messageManager );
       
   164             	}
       
   165             }
       
   166         }
       
   167 
       
   168     return iPhoneTsy;
       
   169     }
       
   170 
       
   171 // ---------------------------------------------------------------------------
       
   172 // CMmPhoneFactoryTsy::EnumeratePhones
       
   173 // Returns the maximum number of supported phone instances
       
   174 // (other items were commented in a header).
       
   175 // ---------------------------------------------------------------------------
       
   176 //
       
   177 TInt CMmPhoneFactoryTsy::EnumeratePhones()
       
   178     {
       
   179     return KMmTsyNumOfSupportedPhones;
       
   180     }
       
   181 
       
   182 // ---------------------------------------------------------------------------
       
   183 // CMmPhoneFactoryTsy::GetPhoneInfo
       
   184 // Index of the requested phone is passed to the client
       
   185 // (other items were commented in a header).
       
   186 // ---------------------------------------------------------------------------
       
   187 //
       
   188 TInt CMmPhoneFactoryTsy::GetPhoneInfo(
       
   189     const TInt aIndex,
       
   190     RTelServer::TPhoneInfo& aInfo )
       
   191     {
       
   192     TInt ret( KErrNotFound );
       
   193     
       
   194     if( aIndex == 0 )
       
   195         {
       
   196         aInfo.iName.Copy( TPtrC( KMmTsyPhoneName ) );
       
   197         aInfo.iNetworkType = KMmTsyNetworkType;
       
   198         aInfo.iNumberOfLines = KMmTsyNumOfSupportedLines;
       
   199         //(TAN) Symbian's comment to iExtension parameter:
       
   200         //The best solution is not to worry about this iExtensions field too
       
   201         //much and to just return one API extension value, and that being the
       
   202         //main API supported by the TSY. If the TSY also supports e.g. GPRS
       
   203         //and/or SAT then the client can find this out using the
       
   204         //RTelServer::IsSupportedByModule method.
       
   205         aInfo.iExtensions = KETelExtMultimodeV1;
       
   206 
       
   207         // Phone found. Change ret value.
       
   208         ret = KErrNone;
       
   209         }
       
   210     
       
   211     return ret;
       
   212     }
       
   213 
       
   214 // ---------------------------------------------------------------------------
       
   215 // CMmPhoneFactoryTsy::IsSupported
       
   216 // Provides information about the supported functional units of
       
   217 // the TSY. This method directs the request to all supported protocol
       
   218 // extensions. If functional unit is supported by any of those protocol
       
   219 // extension the result will be ETrue. Otherwise the method will 
       
   220 // return KErrNone
       
   221 // (other items were commented in a header).
       
   222 // ---------------------------------------------------------------------------
       
   223 //
       
   224 TBool CMmPhoneFactoryTsy::IsSupported( const TInt aFunctionalUnit )
       
   225     {
       
   226     TBool ret = EFalse;
       
   227 
       
   228     switch ( aFunctionalUnit )
       
   229         {
       
   230         //Supported functional units of mmtsy
       
   231         case KETelFuncMobileIccAccess:
       
   232         case KETelFuncMobileNetwork:
       
   233         case KETelFuncMobileIdentity:
       
   234         case KETelFuncMobilePower:
       
   235         case KETelFuncMobileSignal:
       
   236         case KETelFuncMobileDTMF:
       
   237         case KETelFuncMobileUserNetworkAccess:
       
   238         case KETelFuncMobileIdentityService:
       
   239         case KETelFuncMobileCallForwarding:
       
   240         case KETelFuncMobileCallBarring:
       
   241         case KETelFuncMobileCallWaiting:
       
   242         case KETelFuncMobileCallCompletion:
       
   243         case KETelFuncMobileSecurity:
       
   244         case KETelFuncMobileAlternateLineService:
       
   245         case KETelFuncMobileFixedDiallingNumbers:
       
   246         case KETelFuncMobileDataCall:
       
   247         case KETelFuncMobileEmergencyCall:
       
   248         case KETelFuncMobileSmsMessaging:
       
   249         case KETelFuncMobileBroadcastMessaging:
       
   250         case KETelFuncMobileUssdMessaging:
       
   251         case KETelFuncMobileConferenceCall:
       
   252         case KETelFuncMobilePhonebook:
       
   253         case KETelFuncMobileSmsStore:
       
   254         case KETelFuncMobileOwnNumberStore:
       
   255         case KETelFuncMobileEmergencyNumberStore:
       
   256         case KETelFuncMobilePrivacy:
       
   257         case KETelExtMultimodeV1:
       
   258         case KETelExtMultimodeV2:
       
   259         case KETelExtMultimodeV3:
       
   260         case KEtelFuncMobileAPNControlList:
       
   261         case KEtelExtMultimodeV9:
       
   262         case KEtelFuncCellInfo:
       
   263             ret = ETrue;
       
   264             break;
       
   265 
       
   266         //Unsupported functional units
       
   267         //case KETelFuncMobileAlternatingCall:
       
   268         //case KETelFuncMobileMessageWaiting:
       
   269         //case KETelFuncMobileNamStore:
       
   270         //case KETelFuncMobileMultimediaCall:
       
   271         //case KEtelFuncMobileMultimediaCallSettings:
       
   272         //case KETelFuncMobileCost:
       
   273 
       
   274         default:
       
   275             ret = EFalse;
       
   276         }
       
   277 
       
   278     return ret;
       
   279     }
       
   280 
       
   281 // ---------------------------------------------------------------------------
       
   282 // CMmPhoneFactoryTsy::NewSimAtk
       
   283 // Creates CTsySatMessaging object and returns it
       
   284 // (other items were commented in a header).
       
   285 // ---------------------------------------------------------------------------
       
   286 //
       
   287 CTsySatMessagingBase* CMmPhoneFactoryTsy::NewSimAtk( const TDesC& aName )
       
   288     {
       
   289     CTsySatMessagingBase* satMessaging = NULL;
       
   290     
       
   291     if ( KErrNone == aName.CompareF( KSatToolkit ) )
       
   292         {
       
   293 TFLOGSTRING("TSY: CMmPhoneFactoryTsy::NewSimAtk - Starting to open SimAtkTSY");
       
   294 
       
   295         if( iLtsyFactory )
       
   296             {
       
   297             // Get SIM ATK TSY messaging service from LicenseeTsy
       
   298             MLtsyFactoryV1* ptr_v1 = 
       
   299             	static_cast<MLtsyFactoryV1*>( iLtsyFactory );
       
   300      
       
   301 #ifdef USING_CTSY_DISPATCHER     	
       
   302            	satMessaging = ptr_v1->GetSatMessagingService( 
       
   303             	iPhoneTsy->SmsService() );
       
   304 #else
       
   305            	satMessaging = ptr_v1->GetSatMessagingService( );
       
   306 #endif
       
   307             }
       
   308         }
       
   309 
       
   310     return satMessaging;
       
   311     }
       
   312 
       
   313 // ---------------------------------------------------------------------------
       
   314 // extern "C"
       
   315 // The LibEntry function is implemented in another programming
       
   316 // language (ASM?). extern "C" is required to port from other language
       
   317 // ---------------------------------------------------------------------------
       
   318 //
       
   319 extern "C"
       
   320     {
       
   321     IMPORT_C CPhoneFactoryBase* LibEntry(); // Force "Proper Name" export
       
   322     }
       
   323 
       
   324 // ---------------------------------------------------------------------------
       
   325 // LibEntry
       
   326 // A Windows Entry Procedure. The LibEntry() procedure in the
       
   327 // DLL C run-time libraries performs all the necessary initialization
       
   328 // required by the WEPs (Windows Entry Point) they contain. This code is
       
   329 // copied from Symbian's example
       
   330 // Returns: CPhoneFactoryBase*: Pointer to CMmPhoneFactoryTsy class
       
   331 // ---------------------------------------------------------------------------
       
   332 //
       
   333 EXPORT_C CPhoneFactoryBase* LibEntry()
       
   334     {
       
   335 TFLOGSTRING("TSY: CPhoneFactoryBase::LibEntry()...");
       
   336     CMmPhoneFactoryTsy* factory = CMmPhoneFactoryTsy::NewL(); 
       
   337     return factory; 
       
   338     }
       
   339 
       
   340 #ifdef USING_CTSY_DISPATCHER
       
   341 TBool CMmPhoneFactoryTsy::UsingCtsyDispatcher()
       
   342 	{
       
   343 	//function to determine whether the setup is using the CTSY Dispatcher layer.
       
   344 #ifdef USING_CTSY_DISPATCHER 
       
   345 	return ETrue; 
       
   346 #else
       
   347 	return EFalse;
       
   348 #endif
       
   349 	}
       
   350 
       
   351 MLtsyFactoryBase* CMmPhoneFactoryTsy::LoadLibraryL()
       
   352 	{
       
   353 	//load library.  This can either be LicenseeTsy or CtsyDispatcher dlls
       
   354 	TPtrC dllname;
       
   355 	TInt uid3_int;
       
   356 	if(UsingCtsyDispatcher())
       
   357 		{
       
   358 		dllname.Set(KCtsyDispatcherDllName);
       
   359 		uid3_int = KCtsyDispatcherUID3;
       
   360 		}
       
   361 	else
       
   362 		{
       
   363 		dllname.Set(KLicenseeTsyDllName);
       
   364 		uid3_int = KLicenseeTsyUID3;
       
   365 		}
       
   366 	
       
   367 	TFLOGSTRING3("TSY: CMmPhoneFactoryTsy::LoadLibraryL - Loading Dll=%S, UID3=0x%x", &dllname, uid3_int);
       
   368 	
       
   369 	TUidType uid(KNullUid, KNullUid, TUid::Uid(uid3_int));
       
   370 	
       
   371 	User::LeaveIfError(iLoadedLib.Load(dllname));
       
   372 	
       
   373 	// Check the Uid3 is as expected
       
   374 	if(iLoadedLib.Type()[2]!=TUid::Uid(uid3_int))
       
   375 		User::Leave(KErrBadLibraryEntryPoint);
       
   376 	
       
   377 	TFactoryBaseNewL libEntry=(TFactoryBaseNewL)iLoadedLib.Lookup(1);	
       
   378 	MLtsyFactoryBase* factory=(*libEntry)();	// libEntry may leave.
       
   379 	
       
   380 	return factory;
       
   381 	}
       
   382 #endif //USING_CTSY_DISPATCHER
       
   383 
       
   384 //  End of File
       
   385 
       
   386