|
1 // Copyright (c) 2003-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 // Help Launcher module |
|
15 // |
|
16 // |
|
17 |
|
18 #include "hlplch.h" |
|
19 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS |
|
20 #include "hlplch_internal.h" |
|
21 #endif |
|
22 #include <apgcli.h> |
|
23 #include <barsc.h> |
|
24 #include <bautils.h> |
|
25 #include <lch.rsg> |
|
26 |
|
27 EXPORT_C void HlpLauncher::LaunchHelpApplicationL(RWsSession& aWsSession, TUid aUid) |
|
28 /** Launches the help application, passing a help file UID. |
|
29 |
|
30 @param aWsSession Application's window server session |
|
31 @param aUid Help file UID */ |
|
32 { |
|
33 __UHEAP_MARK; |
|
34 TBuf<32> cmdLine; |
|
35 cmdLine.AppendNum((TInt)aUid.iUid); |
|
36 TPtr8 ptr((TText8*)cmdLine.Ptr(), cmdLine.Length(),cmdLine.Length()); |
|
37 DoLaunchHelpApplicationL(aWsSession, ptr); |
|
38 __UHEAP_MARKEND; |
|
39 } |
|
40 |
|
41 EXPORT_C void HlpLauncher::LaunchHelpApplicationL(RWsSession& aWsSession) |
|
42 /** Launches the help application. |
|
43 |
|
44 @param aWsSession Application's window server session */ |
|
45 { |
|
46 __UHEAP_MARK; |
|
47 TBuf8<1> blank = _L8(""); |
|
48 DoLaunchHelpApplicationL(aWsSession, blank); |
|
49 __UHEAP_MARKEND; |
|
50 } |
|
51 |
|
52 EXPORT_C void HlpLauncher::LaunchHelpApplicationL(RWsSession& aWsSession, CArrayFix<TCoeHelpContext>* aContextList) |
|
53 /** Launches the help application, passing an array of help contexts. |
|
54 |
|
55 @param aWsSession Application's window server session |
|
56 @param aContextList Array of help contexts */ |
|
57 { |
|
58 __UHEAP_MARK; |
|
59 |
|
60 CHlpCmdLine* cmdLine=CHlpCmdLine::NewLC(aContextList); |
|
61 DoLaunchHelpApplicationL(aWsSession, cmdLine->CmdLineL()); |
|
62 CleanupStack::PopAndDestroy(); |
|
63 |
|
64 __UHEAP_MARKEND; |
|
65 } |
|
66 |
|
67 void HlpLauncher::DoLaunchHelpApplicationL(RWsSession& aWsSession, const TDesC8& aCmdLine) |
|
68 { |
|
69 TApaTaskList taskList(aWsSession); |
|
70 TApaTask task = taskList.FindApp(KHlpAppUid); |
|
71 if (task.Exists()) |
|
72 { |
|
73 task.SendMessage (KHlpAppWsMsg, aCmdLine); |
|
74 task.BringToForeground(); |
|
75 } |
|
76 else |
|
77 { |
|
78 CApaCommandLine* cmdLine=CApaCommandLine::NewLC(); |
|
79 |
|
80 // INC057477 fix |
|
81 // Get and open the resource file |
|
82 RFs f; |
|
83 CleanupClosePushL(f); |
|
84 |
|
85 User::LeaveIfError(f.Connect()); |
|
86 RResourceFile r; |
|
87 |
|
88 r.OpenL(f, KHelpLauncherResource); |
|
89 CleanupClosePushL(r); |
|
90 |
|
91 // Read the path of the help application from the resource file |
|
92 r.ConfirmSignatureL(); |
|
93 TResourceReader resReader; |
|
94 resReader.SetBuffer(r.AllocReadLC(R_HELP_PATH)); |
|
95 TPtrC16 helpPath = resReader.ReadTPtrC16(); |
|
96 cmdLine->SetExecutableNameL(helpPath); |
|
97 CleanupStack::PopAndDestroy(); // AllocReadLC |
|
98 CleanupStack::PopAndDestroy(); // close r |
|
99 CleanupStack::PopAndDestroy(); // close f |
|
100 |
|
101 cmdLine->SetCommandL(EApaCommandOpen); |
|
102 cmdLine->SetTailEndL(aCmdLine); |
|
103 //EikDll::StartAppL(*cmdLine); |
|
104 RApaLsSession lsSession; |
|
105 User::LeaveIfError(lsSession.Connect()); |
|
106 CleanupClosePushL(lsSession); |
|
107 User::LeaveIfError(lsSession.StartApp(*cmdLine)); |
|
108 CleanupStack::PopAndDestroy(&lsSession); |
|
109 CleanupStack::PopAndDestroy(); //cmdLine |
|
110 } |
|
111 } |
|
112 |
|
113 CHlpCmdLine* CHlpCmdLine::NewL(CArrayFix<TCoeHelpContext>* aContextList) |
|
114 { |
|
115 CHlpCmdLine* self=CHlpCmdLine::NewLC(aContextList); |
|
116 CleanupStack::Pop(); // self |
|
117 return self; |
|
118 } |
|
119 |
|
120 CHlpCmdLine* CHlpCmdLine::NewLC(CArrayFix<TCoeHelpContext>* aContextList) |
|
121 { |
|
122 CHlpCmdLine* self=new(ELeave)CHlpCmdLine(aContextList); |
|
123 CleanupStack::PushL(self); |
|
124 self->ConstructL(); |
|
125 return self; |
|
126 } |
|
127 |
|
128 CHlpCmdLine::CHlpCmdLine(CArrayFix<TCoeHelpContext>* aContextList) |
|
129 :iContextList(aContextList) |
|
130 { |
|
131 } |
|
132 |
|
133 CHlpCmdLine::~CHlpCmdLine() |
|
134 { |
|
135 delete iContextList; |
|
136 delete iCmdLine; |
|
137 } |
|
138 |
|
139 void CHlpCmdLine::ConstructL() |
|
140 { |
|
141 iCmdLine=CBufFlat::NewL(KMaxCmdLineLength); |
|
142 } |
|
143 |
|
144 TPtr8 CHlpCmdLine::CmdLineL() |
|
145 { |
|
146 BuildCmdLineL(); |
|
147 TInt len = iCmdLine->Ptr(0).Size()/sizeof(TText8); |
|
148 TPtr8 ptr((TText8*)iCmdLine->Ptr(0).Ptr(),len,len); |
|
149 |
|
150 return ptr; |
|
151 } |
|
152 |
|
153 void CHlpCmdLine::BuildCmdLineL() |
|
154 { |
|
155 TInt count=iContextList->Count(); |
|
156 iCmdLine->InsertL(iCmdLine->Size(), &count, sizeof(TInt)); |
|
157 for (TInt i=0; i < count; i++) |
|
158 { |
|
159 AddContextL(iContextList->At(i)); |
|
160 } |
|
161 } |
|
162 |
|
163 void CHlpCmdLine::AddContextL(TCoeHelpContext& aContext) |
|
164 { |
|
165 TInt length=aContext.iContext.Size(); |
|
166 iCmdLine->InsertL(iCmdLine->Size(), &length, sizeof(TInt)); |
|
167 iCmdLine->InsertL(iCmdLine->Size(), aContext.iContext.Ptr(), aContext.iContext.Size()); |
|
168 iCmdLine->InsertL(iCmdLine->Size(), &aContext.iMajor, sizeof(TUid)); |
|
169 } |
|
170 |