94 @publishedAll |
88 @publishedAll |
95 @released |
89 @released |
96 */ |
90 */ |
97 EXPORT_C TInt RFbsSession::Connect(RFs& aFileServer) |
91 EXPORT_C TInt RFbsSession::Connect(RFs& aFileServer) |
98 { |
92 { |
99 TInt ret = KErrNone; |
|
100 RFbsSession* thisptr = (RFbsSession*)Dll::Tls(); |
93 RFbsSession* thisptr = (RFbsSession*)Dll::Tls(); |
101 FBS_OST(OstTrace1(GRAPHICS_CONTROL_FUNCTIONS, RFBSSESSION_CONNECT_ENTRY, "> this=0x%08x;", (TUint)thisptr);) |
|
102 if(thisptr) |
94 if(thisptr) |
103 { |
95 { |
104 thisptr->iConnections++; |
96 thisptr->iConnections++; |
105 FBS_OST(OstTraceExt2(GRAPHICS_CONTROL_SEMANTICS, RFBSSESSION_CONNECT_INFO, "# Connected to existing session; this=0x%08x; iConnections=%d;", (TInt)thisptr, thisptr->iConnections);) |
97 return KErrNone; |
106 } |
98 } |
107 else |
99 TInt ret = RFbsSession::DoAlloc(thisptr); |
108 { |
100 if(ret!=KErrNone) |
109 ret = RFbsSession::DoAlloc(thisptr); |
101 return ret; |
110 if(ret!=KErrNone) |
102 return thisptr->DoConnect(aFileServer); |
111 { |
|
112 FBS_OST(OstTrace1(TRACE_ERROR, RFBSSESSION_CONNECT_ERROR, "! DoAlloc returned %d", ret);) |
|
113 } |
|
114 else |
|
115 { |
|
116 ret = thisptr->DoConnect(aFileServer); |
|
117 if(ret!=KErrNone) |
|
118 { |
|
119 FBS_OST(OstTraceExt2(TRACE_ERROR, RFBSSESSION_CONNECT_ERROR2, "! this=0x%08x; DoConnect returned %d", (TInt)thisptr, ret);) |
|
120 } |
|
121 } |
|
122 } |
|
123 |
|
124 FBS_OST(OstTraceExt2(GRAPHICS_CONTROL_FUNCTIONS, RFBSSESSION_CONNECT_EXIT, "< this=0x%08x; ret=%d", (TUint)thisptr, ret);) |
|
125 return ret; |
|
126 } |
103 } |
127 |
104 |
128 /** Creates a session with the Font and Bitmap server. |
105 /** Creates a session with the Font and Bitmap server. |
129 @return KErrNone, if successful; KErrNoMemory if there is not enough memory |
106 @return KErrNone, if successful; KErrNoMemory if there is not enough memory |
130 to create the session; otherwise another of the system-wide error codes. |
107 to create the session; otherwise another of the system-wide error codes. |
131 @publishedAll |
108 @publishedAll |
132 @released |
109 @released |
133 */ |
110 */ |
134 EXPORT_C TInt RFbsSession::Connect() |
111 EXPORT_C TInt RFbsSession::Connect() |
135 { |
112 { |
136 TInt ret = KErrNone; |
|
137 RFbsSession* thisptr = (RFbsSession*)Dll::Tls(); |
113 RFbsSession* thisptr = (RFbsSession*)Dll::Tls(); |
138 FBS_OST(OstTrace1(GRAPHICS_CONTROL_FUNCTIONS, RFBSSESSION_CONNECT2_ENTRY, "> this=0x%08x;", (TUint)thisptr);) |
|
139 if(thisptr) |
114 if(thisptr) |
140 { |
115 { |
141 thisptr->iConnections++; |
116 thisptr->iConnections++; |
142 FBS_OST(OstTraceExt2(GRAPHICS_CONTROL_SEMANTICS, RFBSSESSION_CONNECT2_INFO, "# Connected to existing session; this=0x%08x; iConnections=%d;", (TInt)thisptr, thisptr->iConnections);) |
117 return KErrNone; |
143 } |
118 } |
144 else |
119 TInt ret = RFbsSession::DoAlloc(thisptr); |
145 { |
120 if (ret!=KErrNone) |
146 TInt ret = RFbsSession::DoAlloc(thisptr); |
121 return ret; |
147 if (ret!=KErrNone) |
122 ret = thisptr->iFileServer.Connect(); |
148 { |
123 if(ret!=KErrNone) |
149 FBS_OST(OstTrace1(TRACE_ERROR, RFBSSESSION_CONNECT2_ERROR, "! DoAlloc returned %d", ret);) |
124 { |
150 goto end; |
125 thisptr->Disconnect(); |
151 } |
126 return ret; |
152 |
127 } |
153 ret = thisptr->iFileServer.Connect(); |
128 return thisptr->DoConnect(thisptr->iFileServer); |
154 if(ret!=KErrNone) |
|
155 { |
|
156 thisptr->Disconnect(); |
|
157 FBS_OST(OstTraceExt2(TRACE_ERROR, RFBSSESSION_CONNECT2_ERROR2, "! this=0x%08x; RFs::Connect() returned %d", (TInt)thisptr, ret);) |
|
158 goto end; |
|
159 } |
|
160 |
|
161 ret = thisptr->DoConnect(thisptr->iFileServer); |
|
162 if(ret!=KErrNone) |
|
163 { |
|
164 FBS_OST(OstTraceExt2(TRACE_ERROR, RFBSSESSION_CONNECT2_ERROR3, "! this=0x%08x; DoConnect returned %d", (TInt)thisptr, ret);) |
|
165 } |
|
166 } |
|
167 end: |
|
168 FBS_OST(OstTraceExt2(GRAPHICS_CONTROL_FUNCTIONS, RFBSSESSION_CONNECT2_EXIT, "< this=0x%08x; ret=%d", (TUint)thisptr, ret);) |
|
169 return ret; |
|
170 } |
129 } |
171 |
130 |
172 /** Closes the session with the Font and Bitmap server. |
131 /** Closes the session with the Font and Bitmap server. |
173 @publishedAll |
132 @publishedAll |
174 @released |
133 @released |
175 */ |
134 */ |
176 EXPORT_C void RFbsSession::Disconnect() |
135 EXPORT_C void RFbsSession::Disconnect() |
177 { |
136 { |
178 RFbsSession* thisptr=(RFbsSession*)Dll::Tls(); |
137 RFbsSession* thisptr=(RFbsSession*)Dll::Tls(); |
179 FBS_OST(OstTrace1(GRAPHICS_CONTROL_FUNCTIONS, RFBSSESSION_DISCONNECT_ENTRY, "> this=0x%08x;", (TUint)thisptr);) |
138 if(thisptr==NULL) return; |
180 if(thisptr) |
139 if(thisptr->iConnections>0) |
181 { |
140 { |
182 FBS_OST(TInt tempServerSessionHandle = (thisptr->iHelper) ? thisptr->iHelper->iServerSessionHandle : 0;) |
141 thisptr->iCallBack.iPtr=NULL; |
183 if(thisptr->iConnections>0) |
142 thisptr->iCallBack.CallBack(); |
184 { |
143 // Destructor of CFbsSessionHelper may call SendCommand to cancel an |
185 thisptr->iCallBack.iPtr=NULL; |
144 // outstanding request, therefore destruction must be done before |
186 thisptr->iCallBack.CallBack(); |
145 // iConnections is 0 to avoid an assertion going off. |
187 // Destructor of CFbsSessionHelper may call SendCommand to cancel an |
146 if(thisptr->iConnections==1) |
188 // outstanding request, therefore destruction must be done before |
147 { |
189 // iConnections is 0 to avoid an assertion going off. |
148 delete thisptr->iHelper; |
190 if(thisptr->iConnections==1) |
149 } |
191 { |
150 thisptr->iConnections--; |
192 delete thisptr->iHelper; |
151 } |
193 } |
152 if(thisptr->iConnections==0) |
194 thisptr->iConnections--; |
153 { |
195 } |
154 thisptr->iSharedChunk.Close(); |
196 FBS_OST(TInt tempConnectionCount = thisptr->iConnections;) |
155 thisptr->iLargeBitmapChunk.Close(); |
197 if(thisptr->iConnections==0) |
156 // Call close on the iFileServer regardless of whether this session owns it: |
198 { |
157 // if we don't own it, close will do nothing if there are still open files, |
199 thisptr->iSharedChunk.Close(); |
158 // so always calling close introduces extra safety |
200 thisptr->iLargeBitmapChunk.Close(); |
159 thisptr->iFileServer.Close(); |
201 // Call close on the iFileServer regardless of whether this session owns it: |
160 delete thisptr->iRomFileAddrCache; |
202 // if we don't own it, close will do nothing if there are still open files, |
161 delete thisptr->iScanLineBuffer; |
203 // so always calling close introduces extra safety |
162 delete thisptr->iDecompressionBuffer; |
204 thisptr->iFileServer.Close(); |
163 thisptr->Close(); |
205 delete thisptr->iRomFileAddrCache; |
164 delete thisptr; |
206 delete thisptr->iScanLineBuffer; |
165 Dll::FreeTls(); |
207 delete thisptr->iDecompressionBuffer; |
166 } |
208 thisptr->Close(); |
|
209 delete thisptr; |
|
210 Dll::FreeTls(); |
|
211 } |
|
212 FBS_OST(OstTraceExt3(GRAPHICS_CONTROL_SEMANTICS, RFBSSESSION_DISCONNECT_INFO, "# Disconnected from session; this=0x%08x; iConnections=%d; iSSH=0x%08x", (TInt)thisptr, tempConnectionCount, tempServerSessionHandle);) |
|
213 } |
|
214 FBS_OST(OstTrace1(GRAPHICS_CONTROL_FUNCTIONS, RFBSSESSION_DISCONNECT_EXIT2, "< this=0x%08x;", (TUint)thisptr);) |
|
215 } |
167 } |
216 |
168 |
217 /** Gets the current Font and Bitmap server session. |
169 /** Gets the current Font and Bitmap server session. |
218 @return A pointer to the current session or NULL if Connect() has not been |
170 @return A pointer to the current session or NULL if Connect() has not been |
219 called yet. |
171 called yet. |