1 /* |
1 /* |
2 * Copyright (c) 2007-2008 Nokia Corporation and/or its subsidiary(-ies). |
2 * Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies). |
3 * All rights reserved. |
3 * All rights reserved. |
4 * This component and the accompanying materials are made available |
4 * This component and the accompanying materials are made available |
5 * under the terms of "Eclipse Public License v1.0" |
5 * under the terms of "Eclipse Public License v1.0" |
6 * which accompanies this distribution, and is available |
6 * which accompanies this distribution, and is available |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
44 // ----------------------------------------------------------------------------- |
44 // ----------------------------------------------------------------------------- |
45 // RIAUpdateClient::Open |
45 // RIAUpdateClient::Open |
46 // |
46 // |
47 // ----------------------------------------------------------------------------- |
47 // ----------------------------------------------------------------------------- |
48 // |
48 // |
49 TInt RIAUpdateClient::Open( TBool aToBackground ) |
49 TInt RIAUpdateClient::Open() |
50 { |
50 { |
51 IAUPDATE_TRACE("[IAUPDATE] RIAUpdateClient::Open() begin"); |
51 IAUPDATE_TRACE("[IAUPDATE] RIAUpdateClient::Open() begin"); |
52 TInt error( KErrNone ); |
52 TInt error( KErrNone ); |
53 |
53 |
54 if ( !iConnected ) |
54 if ( !iConnected ) |
55 { |
55 { |
56 if ( aToBackground ) |
56 TRAP( error, ConnectNewAppL( ServiceUid() ) ); |
57 { |
57 if ( error == KErrNone ) |
58 TRAP( error, ConnectNewAppToBackgroundL( ServiceUid() ) ); |
|
59 } |
|
60 else |
|
61 { |
|
62 TRAP( error, ConnectNewAppL( ServiceUid() ) ); |
|
63 } |
|
64 if ( error == KErrNone ) |
|
65 { |
58 { |
66 iConnected = ETrue; |
59 iConnected = ETrue; |
67 CEikonEnv* eikEnv = CEikonEnv::Static(); |
60 CEikonEnv* eikEnv = CEikonEnv::Static(); |
68 if ( eikEnv ) |
61 if ( eikEnv ) |
69 { |
62 { |
75 iData = NULL; |
68 iData = NULL; |
76 TRAP_IGNORE( iData = wgId.AllocL() ); |
69 TRAP_IGNORE( iData = wgId.AllocL() ); |
77 |
70 |
78 TIpcArgs args; |
71 TIpcArgs args; |
79 args.Set( 0, iData ); |
72 args.Set( 0, iData ); |
80 |
73 SendReceive( IAUpdateClientDefines::EIAUpdateServerSendWgId, args ); |
81 SendReceive( IAUpdateClientDefines::EIAUpdateServerSendWgId, args ); |
74 } |
82 } |
|
83 } |
75 } |
84 } |
76 } |
85 IAUPDATE_TRACE_1("[IAUPDATE] error code: %d", error ); |
77 IAUPDATE_TRACE_1("[IAUPDATE] RIAUpdateClient::Open() end error code: %d", error ); |
86 IAUPDATE_TRACE("[IAUPDATE] RIAUpdateClient::Open() begin"); |
|
87 return error; |
78 return error; |
88 } |
79 } |
|
80 |
|
81 // ----------------------------------------------------------------------------- |
|
82 // RIAUpdateClient::OpenToBackroundAsync |
|
83 // |
|
84 // ----------------------------------------------------------------------------- |
|
85 // |
|
86 TInt RIAUpdateClient::OpenToBackroundAsync( TRequestStatus& aStatus ) |
|
87 { |
|
88 IAUPDATE_TRACE("[IAUPDATE] RIAUpdateClient::OpenToBackroundAsync() begin"); |
|
89 TInt error( KErrNone ); |
|
90 if ( !iConnected ) |
|
91 { |
|
92 TRAP( error, StartNewAppToBackgroundL( ServiceUid(), aStatus ) ); |
|
93 } |
|
94 IAUPDATE_TRACE_1("[IAUPDATE] RIAUpdateClient::OpenToBackroundAsync() end error code: %d", error ); |
|
95 return error; |
|
96 } |
|
97 |
|
98 // ----------------------------------------------------------------------------- |
|
99 // RIAUpdateClient::ConnectToApp |
|
100 // |
|
101 // ----------------------------------------------------------------------------- |
|
102 // |
|
103 TInt RIAUpdateClient::ConnectToApp() |
|
104 { |
|
105 IAUPDATE_TRACE("[IAUPDATE] RIAUpdateClient::ConnectToApp() begin"); |
|
106 TInt error( KErrNone ); |
|
107 TName serverName; |
|
108 ServerName(serverName, ServiceUid(), iDifferentiator); |
|
109 TRAP( error,ConnectExistingByNameL( serverName ) ); |
|
110 |
|
111 if ( error == KErrNone ) |
|
112 { |
|
113 iConnected = ETrue; |
|
114 CEikonEnv* eikEnv = CEikonEnv::Static(); |
|
115 if ( eikEnv ) |
|
116 { |
|
117 RWindowGroup owngroup; |
|
118 iOwnWgId = eikEnv->RootWin().Identifier(); |
|
119 |
|
120 TPckg<TInt> wgId( iOwnWgId ); |
|
121 delete iData; |
|
122 iData = NULL; |
|
123 TRAP_IGNORE( iData = wgId.AllocL() ); |
|
124 |
|
125 TIpcArgs args; |
|
126 args.Set( 0, iData ); |
|
127 SendReceive( IAUpdateClientDefines::EIAUpdateServerSendWgId, args ); |
|
128 } |
|
129 } |
|
130 IAUPDATE_TRACE_1("[IAUPDATE] RIAUpdateClient::ConnectToApp() end error code: %d", error ); |
|
131 return error; |
|
132 } |
|
133 |
|
134 |
|
135 |
89 |
136 |
90 // ----------------------------------------------------------------------------- |
137 // ----------------------------------------------------------------------------- |
91 // RIAUpdateClient::Close |
138 // RIAUpdateClient::Close |
92 // |
139 // |
93 // ----------------------------------------------------------------------------- |
140 // ----------------------------------------------------------------------------- |
305 // Inform the caller about the success of the request initializing. |
352 // Inform the caller about the success of the request initializing. |
306 IAUPDATE_TRACE("[IAUPDATE] RIAUpdateClient::SendUpdateRequest() end"); |
353 IAUPDATE_TRACE("[IAUPDATE] RIAUpdateClient::SendUpdateRequest() end"); |
307 return error; |
354 return error; |
308 } |
355 } |
309 |
356 |
310 void RIAUpdateClient::ConnectNewAppToBackgroundL( TUid aAppUid ) |
357 // ----------------------------------------------------------------------------- |
311 { |
358 // RIAUpdateClient::StartNewAppToBackgroundL |
|
359 // |
|
360 // ----------------------------------------------------------------------------- |
|
361 // |
|
362 void RIAUpdateClient::StartNewAppToBackgroundL( TUid aAppUid, TRequestStatus& aStatus ) |
|
363 { |
|
364 IAUPDATE_TRACE("[IAUPDATE] RIAUpdateClient::StartNewAppToBackgroundL() begin"); |
312 TName notUsed; |
365 TName notUsed; |
313 const TUint differentiator = GenerateServerDifferentiatorAndName(notUsed, aAppUid); |
366 iDifferentiator = GenerateServerDifferentiatorAndName(notUsed, aAppUid); |
314 TRequestStatus requestStatusForRendezvous; |
367 |
315 |
|
316 RApaLsSession apa; |
368 RApaLsSession apa; |
317 User::LeaveIfError(apa.Connect()); |
369 User::LeaveIfError(apa.Connect()); |
318 CleanupClosePushL(apa); |
370 CleanupClosePushL(apa); |
319 |
371 |
320 TApaAppInfo info; |
372 TApaAppInfo info; |
321 User::LeaveIfError(apa.GetAppInfo(info, aAppUid)); |
373 User::LeaveIfError(apa.GetAppInfo(info, aAppUid)); |
322 |
374 |
323 CApaCommandLine* cmdLine = CApaCommandLine::NewLC(); |
375 CApaCommandLine* cmdLine = CApaCommandLine::NewLC(); |
324 cmdLine->SetExecutableNameL(info.iFullName); |
376 cmdLine->SetExecutableNameL(info.iFullName); |
325 cmdLine->SetServerRequiredL( differentiator ); |
377 cmdLine->SetServerRequiredL( iDifferentiator ); |
326 cmdLine->SetCommandL(EApaCommandBackground); |
378 cmdLine->SetCommandL(EApaCommandBackground); |
327 |
379 |
328 TThreadId notUsedId; |
380 TThreadId notUsedId; |
329 User::LeaveIfError(apa.StartApp(*cmdLine, notUsedId, &requestStatusForRendezvous)); |
381 User::LeaveIfError(apa.StartApp(*cmdLine, notUsedId, &aStatus)); |
330 |
382 |
331 CleanupStack::PopAndDestroy(2, &apa); // cmdLine and apa |
383 CleanupStack::PopAndDestroy(2, &apa); // cmdLine and apa |
332 |
384 IAUPDATE_TRACE("[IAUPDATE] RIAUpdateClient::StartNewAppToBackgroundL() end"); |
333 User::WaitForRequest(requestStatusForRendezvous); |
385 } |
334 User::LeaveIfError(requestStatusForRendezvous.Int()); |
|
335 |
|
336 TName serverName; |
|
337 ServerName(serverName, aAppUid, differentiator); |
|
338 ConnectExistingByNameL(serverName); |
|
339 } |
|
340 |
|
341 |
386 |
342 |
387 |
343 |
388 |
344 void RIAUpdateClient::ServerName(TName& aServerName, TUid aAppServerUid, TUint aServerDifferentiator) |
389 void RIAUpdateClient::ServerName(TName& aServerName, TUid aAppServerUid, TUint aServerDifferentiator) |
345 { |
390 { |