|
1 // Copyright (c) 2007-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 #include "tdirectgdieglcontent_client.h" |
|
17 #include "tdirectgdieglcontent_clientserver.h" |
|
18 #include <graphics/sgimage.h> |
|
19 |
|
20 /** |
|
21 Starts the server process. Simultaneous launching |
|
22 of two such processes should be detected when the second one attempts to |
|
23 create the server object, failing with KErrAlreadyExists. |
|
24 @return KErrNone if successful, error code if server startup failed. |
|
25 */ |
|
26 TInt REglContentSession::StartServer() |
|
27 { |
|
28 const TUidType serverUid(KNullUid, KNullUid, KServerUid3); |
|
29 TInt r = iServer.Create(KEglContentServerName, KNullDesC, serverUid); |
|
30 if(r != KErrNone) |
|
31 return r; |
|
32 TRequestStatus stat; |
|
33 iServer.Rendezvous(stat); |
|
34 if(stat != KRequestPending) |
|
35 iServer.Kill(0); // abort startup |
|
36 else |
|
37 iServer.Resume(); // logon OK - start the server |
|
38 User::WaitForRequest(stat); // wait for start or death |
|
39 // we can't use the 'exit reason' if the server panicked as this |
|
40 // is the panic 'reason' and may be '0' which cannot be distinguished |
|
41 // from KErrNone |
|
42 r = (iServer.ExitType() == EExitPanic) ? KErrGeneral : stat.Int(); |
|
43 return r; |
|
44 } |
|
45 |
|
46 /** |
|
47 Connect to the server, attempting to start it if necessary |
|
48 @return KErrNone if successful, error code if connection to server failed. |
|
49 */ |
|
50 TInt REglContentSession::Connect() |
|
51 { |
|
52 TInt retry = 2; |
|
53 for(;;) |
|
54 { |
|
55 TInt r = CreateSession(KEglContentServerName, TVersion(0, 0, 0), 1); |
|
56 if((r != KErrNotFound) && (r != KErrServerTerminated)) |
|
57 return r; |
|
58 if((--retry) == 0) |
|
59 return r; |
|
60 r = StartServer(); |
|
61 if((r != KErrNone) && (r != KErrAlreadyExists)) |
|
62 return r; |
|
63 } |
|
64 } |
|
65 |
|
66 /** |
|
67 Force server termination and close server session. |
|
68 */ |
|
69 void REglContentSession::Close() |
|
70 { |
|
71 SendReceive(ETerminateServer, TIpcArgs()); |
|
72 |
|
73 // wait until process terminate |
|
74 TRequestStatus status; |
|
75 iServer.Logon(status); |
|
76 User::WaitForRequest(status); |
|
77 |
|
78 iServer.Close(); |
|
79 RSessionBase::Close(); |
|
80 } |
|
81 |
|
82 /** |
|
83 Send a request to the server for an image in sync mode. Function returns when the image is available. |
|
84 @param aImageId reference to drawable id for image id storing. |
|
85 @return KErrNone if successful, error code if request sending failed. |
|
86 */ |
|
87 TInt REglContentSession::GetSyncImage(TSgDrawableId& aImageId) |
|
88 { |
|
89 TPckg<TSgDrawableId> idPckg(aImageId); |
|
90 return SendReceive(EGetSyncImage, TIpcArgs(&idPckg)); |
|
91 } |
|
92 |
|
93 /** |
|
94 Send a request to the server for an image in async mode. Function returns when the image is available. |
|
95 Command to render the next images is issued. |
|
96 @param aImageId reference to drawable id for image id storing. |
|
97 @param aFrameNumber reference to variable to store frame number |
|
98 @return KErrNone if successful, error code if request sending failed. |
|
99 */ |
|
100 TInt REglContentSession::GetAsyncImage(TSgDrawableId& aImageId, TInt& aFrameNumber) |
|
101 { |
|
102 TPckg<TSgDrawableId> idPckg(aImageId); |
|
103 TPckg<TInt> fnumPckg(aFrameNumber); |
|
104 return SendReceive(EGetAsyncImage, TIpcArgs(&idPckg, &fnumPckg)); |
|
105 } |
|
106 |
|
107 /** |
|
108 Send a request to the server for an image in async debug mode. Function returns when the image is available. |
|
109 Command to render the next image (only one) is issued. |
|
110 @param aImageId reference to drawable id for image id storing. |
|
111 @param aFrameNumber reference to variable to store frame number |
|
112 @return KErrNone if successful, error code if request sending failed. |
|
113 */ |
|
114 TInt REglContentSession::GetAsyncImageDebug(TSgDrawableId& aImageId, TInt& aFrameNumber) |
|
115 { |
|
116 TPckg<TSgDrawableId> idPckg(aImageId); |
|
117 TPckg<TInt> fnumPckg(aFrameNumber); |
|
118 return SendReceive(EGetAsyncImageDebug, TIpcArgs(&idPckg, &fnumPckg)); |
|
119 } |