1 // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). |
1 // Copyright (c) 1997-2010 Nokia Corporation and/or its subsidiary(-ies). |
2 // All rights reserved. |
2 // All rights reserved. |
3 // This component and the accompanying materials are made available |
3 // This component and the accompanying materials are made available |
4 // under the terms of "Eclipse Public License v1.0" |
4 // under the terms of "Eclipse Public License v1.0" |
5 // which accompanies this distribution, and is available |
5 // which accompanies this distribution, and is available |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
248 TName foundName; |
254 TName foundName; |
249 TInt findHandle=0; |
255 TInt findHandle=0; |
250 TInt found=iTsyModulesCon->FindByName(findHandle,name,foundName); // Is already loaded? |
256 TInt found=iTsyModulesCon->FindByName(findHandle,name,foundName); // Is already loaded? |
251 if(found==KErrNone) |
257 if(found==KErrNone) |
252 { // The TSY is already loaded, we'll just open, and bump up the reference count. |
258 { // The TSY is already loaded, we'll just open, and bump up the reference count. |
253 LOGTEXT("LoadPhoneModuleL\tTSY already loaded - inc ref count"); |
259 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPHONEMANAGER_LOADPHONEMODULEL_1, "LoadPhoneModuleL\tTSY already loaded - inc ref count"); |
254 CPhoneFactoryBase* s=REINTERPRET_CAST(CPhoneFactoryBase*,iTsyModulesCon->At(findHandle)); |
260 CPhoneFactoryBase* s=REINTERPRET_CAST(CPhoneFactoryBase*,iTsyModulesCon->At(findHandle)); |
255 s->Open(); |
261 s->Open(); |
256 return s; |
262 return s; |
257 } |
263 } |
258 |
264 |
259 RLibrary lib; |
265 RLibrary lib; |
260 #ifdef _DEBUG |
266 OstTraceDefExt1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPHONEMANAGER_LOADPHONEMODULEL_2, "Loading %S", aFileName); |
261 TBuf8<128> buf; |
|
262 buf.Copy(aFileName); |
|
263 #endif // _DEBUG |
|
264 LOGTEXT2("Loading %S", &buf); |
|
265 TInt r=lib.Load(aFileName); |
267 TInt r=lib.Load(aFileName); |
266 if (r!=KErrNone) |
268 if (r!=KErrNone) |
267 User::Leave(r); |
269 User::Leave(r); |
268 LOGTEXT2("Loaded %S", &buf); |
270 OstTraceDefExt1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPHONEMANAGER_LOADPHONEMODULEL_3, "Loaded %S", aFileName); |
269 TCleanupItem libClose(CloseLibrary,&lib); |
271 TCleanupItem libClose(CloseLibrary,&lib); |
270 CleanupStack::PushL(libClose); |
272 CleanupStack::PushL(libClose); |
271 |
273 |
272 // Check the Uid2 |
274 // Check the Uid2 |
273 if(lib.Type()[1]!=TUid::Uid(KUidUnicodeEtelServerModule)) |
275 if(lib.Type()[1]!=TUid::Uid(KUidUnicodeEtelServerModule)) |
274 User::Leave(KErrBadLibraryEntryPoint); |
276 User::Leave(KErrBadLibraryEntryPoint); |
275 |
277 |
276 TPhoneFactoryBaseNewL libEntry=(TPhoneFactoryBaseNewL)lib.Lookup(1); |
278 TPhoneFactoryBaseNewL libEntry=(TPhoneFactoryBaseNewL)lib.Lookup(1); |
277 if (libEntry==NULL) |
279 if (libEntry==NULL) |
278 User::Leave(KErrBadLibraryEntryPoint); |
280 User::Leave(KErrBadLibraryEntryPoint); |
279 LOGTEXT("About to get CPhoneFactoryBase ptr"); |
281 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPHONEMANAGER_LOADPHONEMODULEL_4, "About to get CPhoneFactoryBase ptr"); |
280 CPhoneFactoryBase* s=NULL; |
282 CPhoneFactoryBase* s=NULL; |
281 s=(*libEntry)(); // libEntry may leave. |
283 s=(*libEntry)(); // libEntry may leave. |
282 if(s==NULL) |
284 if(s==NULL) |
283 User::Leave(KErrNoMemory); |
285 User::Leave(KErrNoMemory); |
284 LOGTEXT("Got CPhoneFactoryBase ptr"); |
286 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPHONEMANAGER_LOADPHONEMODULEL_5, "Got CPhoneFactoryBase ptr"); |
285 TRAPD(error, s->ConstructL(lib)); |
287 TRAPD(error, s->ConstructL(lib)); |
286 if(error) |
288 if(error) |
287 { |
289 { |
288 s->Close(); |
290 s->Close(); |
289 User::Leave(error); |
291 User::Leave(error); |
469 return err; |
471 return err; |
470 _LIT(KDash,"-"); |
472 _LIT(KDash,"-"); |
471 TName newName(tsyName); |
473 TName newName(tsyName); |
472 newName.Append(KDash); |
474 newName.Append(KDash); |
473 newName.Append(infoToMatch.iName); // Create unique name |
475 newName.Append(infoToMatch.iName); // Create unique name |
474 LOGTEXT2("new name = %S", &newName); |
476 OstTraceDefExt1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPHONEMANAGER_RENAMEDUPLICATEPHONENAME_1, "new name = %S", newName); |
475 LOGTEXT2("tsy name = %S", &tsyName); |
477 OstTraceDefExt1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPHONEMANAGER_RENAMEDUPLICATEPHONENAME_2, "tsy name = %S", tsyName); |
476 LOGTEXT2("old name = %S", &infoToMatch.iName); |
478 OstTraceDefExt1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPHONEMANAGER_RENAMEDUPLICATEPHONENAME_3, "old name = %S", infoToMatch.iName); |
477 TRAPD(ret,StoreDuplicateNameL(tsyName,infoToMatch.iName,newName));// even if this returns with |
479 TRAPD(ret,StoreDuplicateNameL(tsyName,infoToMatch.iName,newName));// even if this returns with |
478 //KErrAlreadyExists, carry on searching for another match |
480 //KErrAlreadyExists, carry on searching for another match |
479 if (ret!=KErrNone && ret!=KErrAlreadyExists) |
481 if (ret!=KErrNone && ret!=KErrAlreadyExists) |
480 return ret; |
482 return ret; |
481 } |
483 } |