|
1 // Copyright (c) 2008-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 // |
|
15 |
|
16 |
|
17 #include "cctsydispatcherfactory.h" |
|
18 #include "cmessagerouter.h" |
|
19 |
|
20 #include <ctsy/serviceapi/ctsysatmessagingbase.h> |
|
21 |
|
22 #include <ctsy/ltsy/ltsylogger.h> |
|
23 #include "testsattsyfactory.h" |
|
24 |
|
25 #include <ctsy/ltsy/mltsydispatchfactory.h> |
|
26 |
|
27 |
|
28 CCtsyDispatcherFactoryV1* CCtsyDispatcherFactoryV1::NewL() |
|
29 { |
|
30 TSYLOGENTRYEXIT; |
|
31 CCtsyDispatcherFactoryV1* self = new (ELeave) CCtsyDispatcherFactoryV1; |
|
32 CleanupStack::PushL(self); |
|
33 self->ConstructL(); |
|
34 CleanupStack::Pop(self); |
|
35 return self; |
|
36 } |
|
37 |
|
38 CCtsyDispatcherFactoryV1::CCtsyDispatcherFactoryV1() |
|
39 { |
|
40 } |
|
41 |
|
42 void CCtsyDispatcherFactoryV1::ConstructL() |
|
43 { |
|
44 TSYLOGENTRYEXIT; |
|
45 } |
|
46 |
|
47 CCtsyDispatcherFactoryV1::~CCtsyDispatcherFactoryV1() |
|
48 { |
|
49 iloadedLib.Close(); |
|
50 delete iMessageRouter; |
|
51 } |
|
52 |
|
53 MLtsyFactoryBase::TCtsyInterfaceVersion CCtsyDispatcherFactoryV1::Version() |
|
54 { |
|
55 TSYLOGENTRYEXIT; |
|
56 return MLtsyFactoryBase::EIfVersion1; |
|
57 } |
|
58 |
|
59 void CCtsyDispatcherFactoryV1::Release() |
|
60 { |
|
61 TSYLOGENTRYEXIT; |
|
62 delete this; |
|
63 } |
|
64 |
|
65 MMessageRouter* CCtsyDispatcherFactoryV1::GetMessageRouter(MmMessageManagerCallback& aMessageManager) |
|
66 { |
|
67 TSYLOGENTRYEXIT; |
|
68 if (!iMessageRouter) |
|
69 { |
|
70 TInt err = KErrNone; |
|
71 TRAP(err, iMessageRouter = CMessageRouter::NewL(aMessageManager)); |
|
72 } |
|
73 return iMessageRouter; |
|
74 } |
|
75 |
|
76 CTsySatMessagingBase* CCtsyDispatcherFactoryV1::GetSatMessagingService(MCtsySatService& aSatMessagingService) |
|
77 { |
|
78 TSYLOGENTRYEXIT; |
|
79 //create message router to pass to STK CTSY |
|
80 CTsySatMessagingBase* satbase = NULL; |
|
81 TRAP_IGNORE(satbase = GetSatMessagingServiceL(aSatMessagingService)); |
|
82 return satbase; |
|
83 } |
|
84 |
|
85 CTsySatMessagingBase* CCtsyDispatcherFactoryV1::GetSatMessagingServiceL(MCtsySatService& aSatMessagingService) |
|
86 { |
|
87 |
|
88 // When used by a licensee the TEST_CODE macro should be undefined and |
|
89 // the licensee must provide an implementation for the GetSatMessagingService |
|
90 // method in their dispatcher factory implementation |
|
91 |
|
92 #define TEST_CODE |
|
93 #ifndef TEST_CODE |
|
94 |
|
95 __ASSERT_DEBUG(iMessageRouter, CtsyDispatcherPanic(EInvalidNullPtr)); |
|
96 return iMessageRouter->iLtsyFactoryV1->GetSatMessagingService(aSatMessagingService); |
|
97 |
|
98 #else |
|
99 |
|
100 // Our test SAT TSY component is loaded only when the dispatcher is used in our |
|
101 // test environment. |
|
102 _LIT(KSatDllName, "cstktsy.dll"); |
|
103 User::LeaveIfError(iloadedLib.Load(KSatDllName)); |
|
104 typedef CSatTsyFactory* (*CSatTsyNewLC)(); |
|
105 CSatTsyNewLC libEntry = (CSatTsyNewLC)iloadedLib.Lookup(1); |
|
106 |
|
107 CSatTsyFactory* satfactory = (*libEntry)(); // libEntry may leave. |
|
108 CSatTsyFactory::TSatTsyPtrContainer satptr = satfactory->CreateSatTsyL(*iMessageRouter,aSatMessagingService); |
|
109 |
|
110 CleanupStack::PopAndDestroy(satfactory); |
|
111 iMessageRouter->SetSatMessageManager(*satptr.iSatTsyMessageManagerCallback); |
|
112 MStkTsyCallOrigin* origin = satptr.iSatTsy; |
|
113 iMessageRouter->SetSatCallOriginInterface(*origin); |
|
114 return satptr.iSatTsy; |
|
115 #endif |
|
116 } |
|
117 |
|
118 EXPORT_C MLtsyFactoryBase* CtsyDispatcherFactoryL() |
|
119 { |
|
120 TSYLOGENTRYEXIT; |
|
121 CCtsyDispatcherFactoryV1* factory = CCtsyDispatcherFactoryV1::NewL(); |
|
122 return factory; |
|
123 } |