|
1 /* |
|
2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: VideoOperatorService class implementation. |
|
15 * |
|
16 */ |
|
17 |
|
18 // Version : |
|
19 |
|
20 // INCLUDE FILES |
|
21 |
|
22 #include <qdesktopservices.h> |
|
23 #include <qurl.h> |
|
24 |
|
25 #include <e32base.h> |
|
26 #include <eikenv.h> |
|
27 #include <eikappui.h> |
|
28 #include <apgcli.h> |
|
29 |
|
30 #include "videooperatorservice.h" |
|
31 #include "videocollectionviewutils.h" |
|
32 #include "videocollectioncenrepdefs.h" |
|
33 #include "videocollectiontrace.h" |
|
34 |
|
35 // --------------------------------------------------------------------------- |
|
36 // Constructor |
|
37 // --------------------------------------------------------------------------- |
|
38 // |
|
39 VideoOperatorService::VideoOperatorService(QObject *parent) : |
|
40 QObject(parent) |
|
41 { |
|
42 FUNC_LOG; |
|
43 } |
|
44 |
|
45 // --------------------------------------------------------------------------- |
|
46 // load |
|
47 // --------------------------------------------------------------------------- |
|
48 // |
|
49 bool VideoOperatorService::load(int titleKey, int iconKey, int serviceUriKey, int appUidKey) |
|
50 { |
|
51 FUNC_LOG; |
|
52 VideoCollectionViewUtils& utils = VideoCollectionViewUtils::instance(); |
|
53 |
|
54 mTitle = utils.getCenRepStringValue(titleKey); |
|
55 mIconResource = utils.getCenRepStringValue(iconKey); |
|
56 mServiceUri = utils.getCenRepStringValue(serviceUriKey); |
|
57 mApplicationUid = utils.getCenRepIntValue(appUidKey); |
|
58 |
|
59 // Icon is required, either service uri or application uid is required. |
|
60 if(mIconResource.isEmpty() && (mServiceUri.isEmpty() || mApplicationUid > 0)) |
|
61 { |
|
62 return false; |
|
63 } |
|
64 |
|
65 return true; |
|
66 } |
|
67 |
|
68 // --------------------------------------------------------------------------- |
|
69 // title |
|
70 // --------------------------------------------------------------------------- |
|
71 // |
|
72 const QString VideoOperatorService::title() const |
|
73 { |
|
74 return mTitle; |
|
75 } |
|
76 |
|
77 // --------------------------------------------------------------------------- |
|
78 // iconResource |
|
79 // --------------------------------------------------------------------------- |
|
80 // |
|
81 const QString VideoOperatorService::iconResource() const |
|
82 { |
|
83 return mIconResource; |
|
84 } |
|
85 |
|
86 // --------------------------------------------------------------------------- |
|
87 // launchService |
|
88 // --------------------------------------------------------------------------- |
|
89 // |
|
90 void VideoOperatorService::launchService() |
|
91 { |
|
92 FUNC_LOG; |
|
93 |
|
94 if(!mServiceUri.isEmpty()) |
|
95 { |
|
96 INFO_1("VideoOperatorService::launchService() starting url: %S", mServiceUri); |
|
97 QDesktopServices::openUrl(QUrl(mServiceUri)); |
|
98 } |
|
99 else |
|
100 { |
|
101 INFO_1("VideoOperatorService::launchService() starting application 0x%x", mApplicationUid); |
|
102 TRAP_IGNORE(launchApplicationL(TUid::Uid(mApplicationUid), 0)); |
|
103 } |
|
104 } |
|
105 |
|
106 // --------------------------------------------------------------------------- |
|
107 // launchApplicationL |
|
108 // --------------------------------------------------------------------------- |
|
109 // |
|
110 void VideoOperatorService::launchApplicationL(const TUid uid, TInt viewId) |
|
111 { |
|
112 CEikonEnv *eikEnv = CEikonEnv::Static(); |
|
113 |
|
114 if (viewId > 0 && eikEnv) { |
|
115 TVwsViewId view(uid, TUid::Uid(viewId)); |
|
116 eikEnv->EikAppUi()->ActivateViewL(view); |
|
117 } else |
|
118 { |
|
119 RWsSession wsSession; |
|
120 User::LeaveIfError(wsSession.Connect()); |
|
121 CleanupClosePushL<RWsSession>(wsSession); |
|
122 |
|
123 // TApaAppInfo size is greater then 1024 bytes |
|
124 // so its instances should not be created on the stack. |
|
125 TApaAppInfo* appInfo = new (ELeave) TApaAppInfo; |
|
126 CleanupStack::PushL(appInfo); |
|
127 TApaAppCapabilityBuf capabilityBuf; |
|
128 RApaLsSession appArcSession; |
|
129 User::LeaveIfError(appArcSession.Connect()); |
|
130 CleanupClosePushL<RApaLsSession>(appArcSession); |
|
131 |
|
132 User::LeaveIfError(appArcSession.GetAppInfo(*appInfo, uid)); |
|
133 User::LeaveIfError(appArcSession.GetAppCapability( |
|
134 capabilityBuf, uid)); |
|
135 |
|
136 TApaAppCapability &caps = capabilityBuf(); |
|
137 CApaCommandLine *cmdLine = CApaCommandLine::NewLC(); |
|
138 cmdLine->SetExecutableNameL(appInfo->iFullName); |
|
139 |
|
140 if (caps.iLaunchInBackground) { |
|
141 cmdLine->SetCommandL(EApaCommandBackground); |
|
142 } else { |
|
143 cmdLine->SetCommandL(EApaCommandRun); |
|
144 } |
|
145 |
|
146 cmdLine->SetTailEndL(KNullDesC8); |
|
147 |
|
148 User::LeaveIfError(appArcSession.StartApp(*cmdLine)); |
|
149 |
|
150 CleanupStack::PopAndDestroy(cmdLine); |
|
151 CleanupStack::PopAndDestroy(&appArcSession); |
|
152 CleanupStack::PopAndDestroy(appInfo); |
|
153 |
|
154 CleanupStack::PopAndDestroy(&wsSession); |
|
155 } |
|
156 } |
|
157 |
|
158 // End of file. |