|
1 /* |
|
2 * Copyright (c) 2001-2006 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 the License "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: EAP and WLAN authentication protocols. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // This is enumeration of EAPOL source code. |
|
20 #if defined(USE_EAP_MINIMUM_RELEASE_TRACES) |
|
21 #undef EAP_FILE_NUMBER_ENUM |
|
22 #define EAP_FILE_NUMBER_ENUM 143 |
|
23 #undef EAP_FILE_NUMBER_DATE |
|
24 #define EAP_FILE_NUMBER_DATE 1127594498 |
|
25 #endif //#if defined(USE_EAP_MINIMUM_RELEASE_TRACES) |
|
26 |
|
27 |
|
28 #include <stdio.h> |
|
29 |
|
30 #include "eap_am_file_input_symbian.h" |
|
31 |
|
32 //---------------------------------------------------------------------------------------------------- |
|
33 |
|
34 /** |
|
35 * The destructor of the eap_am_file_input_symbian_c class does nothing special. |
|
36 */ |
|
37 EAP_FUNC_EXPORT eap_am_file_input_symbian_c::~eap_am_file_input_symbian_c() |
|
38 { |
|
39 file_close(); |
|
40 |
|
41 delete m_input_buffer; |
|
42 m_input_buffer = 0; |
|
43 } |
|
44 |
|
45 //---------------------------------------------------------------------------------------------------- |
|
46 |
|
47 /** |
|
48 * The constructor of the eap_am_file_input_symbian_c does nothing special. |
|
49 */ |
|
50 EAP_FUNC_EXPORT eap_am_file_input_symbian_c::eap_am_file_input_symbian_c( |
|
51 abs_eap_am_tools_c * const tools) |
|
52 : m_am_tools(tools) |
|
53 , m_is_valid(false) |
|
54 , m_input_buffer(0) |
|
55 , m_input_buffer_offset(0ul) |
|
56 { |
|
57 m_input_buffer = new TBuf8<EAP_AM_FILE_INPUT_BUFFER_SIZE>; |
|
58 if (m_input_buffer == 0) |
|
59 { |
|
60 return; |
|
61 } |
|
62 |
|
63 set_is_valid(); |
|
64 } |
|
65 |
|
66 //---------------------------------------------------------------------------------------------------- |
|
67 |
|
68 /** |
|
69 * This function checks the file of name file_name exists. |
|
70 */ |
|
71 EAP_FUNC_EXPORT eap_status_e eap_am_file_input_symbian_c::file_exists(const eap_variable_data_c * const file_name) |
|
72 { |
|
73 eap_am_file_input_symbian_c file(m_am_tools); |
|
74 |
|
75 eap_status_e status = file.file_open( |
|
76 file_name, |
|
77 eap_file_io_direction_read); |
|
78 |
|
79 if (status == eap_status_ok) |
|
80 { |
|
81 (void)file.file_close(); |
|
82 } |
|
83 |
|
84 return EAP_STATUS_RETURN(m_am_tools, status); |
|
85 } |
|
86 |
|
87 //---------------------------------------------------------------------------------------------------- |
|
88 |
|
89 EAP_FUNC_EXPORT eap_status_e eap_am_file_input_symbian_c::file_delete( |
|
90 const eap_variable_data_c * const /* file_name */) |
|
91 { |
|
92 return EAP_STATUS_RETURN(m_am_tools, eap_status_not_supported); |
|
93 } |
|
94 |
|
95 //---------------------------------------------------------------------------------------------------- |
|
96 |
|
97 /** |
|
98 * This function copies the file source_file_name to file target_file_name. |
|
99 */ |
|
100 EAP_FUNC_EXPORT eap_status_e eap_am_file_input_symbian_c::file_copy( |
|
101 const eap_variable_data_c * const target_file_name, |
|
102 const eap_variable_data_c * const source_file_name) |
|
103 { |
|
104 eap_am_file_input_symbian_c read_file(m_am_tools); |
|
105 |
|
106 eap_status_e status = read_file.file_open( |
|
107 source_file_name, |
|
108 eap_file_io_direction_read); |
|
109 if (status != eap_status_ok) |
|
110 { |
|
111 EAP_TRACE_DEBUG( |
|
112 m_am_tools, |
|
113 TRACE_FLAGS_DEFAULT, |
|
114 (EAPL("ERROR: file_copy(): Cannot open source file %s\n"), |
|
115 source_file_name->get_data(source_file_name->get_data_length()))); |
|
116 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
117 return EAP_STATUS_RETURN(m_am_tools, status); |
|
118 } |
|
119 |
|
120 |
|
121 eap_am_file_input_symbian_c write_file(m_am_tools); |
|
122 |
|
123 status = write_file.file_open( |
|
124 target_file_name, |
|
125 eap_file_io_direction_write); |
|
126 if (status != eap_status_ok) |
|
127 { |
|
128 EAP_TRACE_DEBUG( |
|
129 m_am_tools, |
|
130 TRACE_FLAGS_DEFAULT, |
|
131 (EAPL("ERROR: file_copy(): Cannot open target file %s\n"), |
|
132 target_file_name->get_data(target_file_name->get_data_length()))); |
|
133 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
134 return EAP_STATUS_RETURN(m_am_tools, status); |
|
135 } |
|
136 |
|
137 |
|
138 eap_variable_data_c buffer(m_am_tools); |
|
139 status = buffer.init(EAP_AM_FILE_INPUT_BUFFER_SIZE); |
|
140 if (status != eap_status_ok) |
|
141 { |
|
142 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
143 return EAP_STATUS_RETURN(m_am_tools, status); |
|
144 } |
|
145 |
|
146 |
|
147 bool end_of_file(false); |
|
148 |
|
149 while(end_of_file == false) |
|
150 { |
|
151 status = read_file.file_read(&buffer); |
|
152 if (status == eap_status_end_of_file) |
|
153 { |
|
154 EAP_TRACE_DEBUG( |
|
155 m_am_tools, |
|
156 TRACE_FLAGS_DEFAULT, |
|
157 (EAPL("file_copy(): End of file.\n"))); |
|
158 end_of_file = true; |
|
159 } |
|
160 else if (status != eap_status_ok) |
|
161 { |
|
162 eap_status_string_c status_string; |
|
163 EAP_TRACE_DEBUG( |
|
164 m_am_tools, |
|
165 TRACE_FLAGS_DEFAULT, |
|
166 (EAPL("ERROR: file_copy(): file_read(): status = %s\n"), |
|
167 status_string.get_status_string(status))); |
|
168 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
169 return EAP_STATUS_RETURN(m_am_tools, status); |
|
170 } |
|
171 |
|
172 EAP_TRACE_DATA_DEBUG( |
|
173 m_am_tools, |
|
174 TRACE_FLAGS_DEFAULT, |
|
175 (EAPL("read data"), |
|
176 buffer.get_data(), |
|
177 buffer.get_data_length())); |
|
178 |
|
179 status = write_file.file_write(&buffer); |
|
180 if (status != eap_status_ok) |
|
181 { |
|
182 eap_status_string_c status_string; |
|
183 EAP_TRACE_DEBUG( |
|
184 m_am_tools, |
|
185 TRACE_FLAGS_DEFAULT, |
|
186 (EAPL("ERROR: file_copy(): file_write(): status = %s\n"), |
|
187 status_string.get_status_string(status))); |
|
188 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
189 return EAP_STATUS_RETURN(m_am_tools, status); |
|
190 } |
|
191 } // while() |
|
192 |
|
193 write_file.file_close(); |
|
194 read_file.file_close(); |
|
195 |
|
196 EAP_TRACE_DEBUG( |
|
197 m_am_tools, |
|
198 TRACE_FLAGS_DEFAULT, |
|
199 (EAPL("file_copy(): OK\n"))); |
|
200 |
|
201 return EAP_STATUS_RETURN(m_am_tools, eap_status_ok); |
|
202 } |
|
203 |
|
204 //---------------------------------------------------------------------------------------------------- |
|
205 |
|
206 /** |
|
207 * This function returns size of a file. |
|
208 */ |
|
209 EAP_FUNC_EXPORT u32_t eap_am_file_input_symbian_c::file_size() |
|
210 { |
|
211 TInt aSize(0ul); |
|
212 |
|
213 TInt size_status = m_File.Size(aSize); |
|
214 |
|
215 if (size_status != KErrNone) |
|
216 { |
|
217 return 0ul; |
|
218 } |
|
219 |
|
220 return static_cast<u32_t>(aSize); |
|
221 } |
|
222 |
|
223 //---------------------------------------------------------------------------------------------------- |
|
224 |
|
225 /** |
|
226 * This function reads data from file. |
|
227 * Maximum size read is the buffer size. |
|
228 */ |
|
229 EAP_FUNC_EXPORT eap_status_e eap_am_file_input_symbian_c::file_read(eap_variable_data_c * const buffer) |
|
230 { |
|
231 TPtr8 tmp(buffer->get_buffer(buffer->get_buffer_length()), buffer->get_buffer_length()); |
|
232 |
|
233 TInt ReadStatus = m_File.Read(tmp); |
|
234 |
|
235 if (ReadStatus != KErrNone |
|
236 || tmp.Length() == 0UL |
|
237 || tmp.Ptr() == 0) |
|
238 { |
|
239 buffer->set_data_length(0ul); |
|
240 return EAP_STATUS_RETURN(m_am_tools, eap_status_end_of_file); |
|
241 } |
|
242 else |
|
243 { |
|
244 buffer->set_data_length(tmp.Length()); |
|
245 return EAP_STATUS_RETURN(m_am_tools, eap_status_ok); |
|
246 } |
|
247 } |
|
248 |
|
249 //---------------------------------------------------------------------------------------------------- |
|
250 |
|
251 /** |
|
252 * This function write data to a file. |
|
253 * Maximum size write is the buffer size. |
|
254 */ |
|
255 EAP_FUNC_EXPORT eap_status_e eap_am_file_input_symbian_c::file_write(const eap_variable_data_c * const buffer) |
|
256 { |
|
257 TPtr8 tmp(buffer->get_data(), buffer->get_data_length()); |
|
258 |
|
259 TInt WriteStatus = m_File.Write(tmp); |
|
260 |
|
261 if (WriteStatus != KErrNone) |
|
262 { |
|
263 return EAP_STATUS_RETURN(m_am_tools, eap_status_file_write_failed); |
|
264 } |
|
265 |
|
266 WriteStatus = m_File.Flush(); |
|
267 |
|
268 if (WriteStatus != KErrNone) |
|
269 { |
|
270 return EAP_STATUS_RETURN(m_am_tools, eap_status_file_write_failed); |
|
271 } |
|
272 |
|
273 return EAP_STATUS_RETURN(m_am_tools, eap_status_ok); |
|
274 } |
|
275 |
|
276 //---------------------------------------------------------------------------------------------------- |
|
277 |
|
278 const u32_t EAP_MAX_FILENAME_LENGTH = 128; |
|
279 |
|
280 /** |
|
281 * This function opens file of name file_name. |
|
282 */ |
|
283 EAP_FUNC_EXPORT eap_status_e eap_am_file_input_symbian_c::file_open( |
|
284 const eap_variable_data_c * const file_name, |
|
285 const eap_file_io_direction_e dir) |
|
286 { |
|
287 TBuf8<EAP_MAX_FILENAME_LENGTH> tmpFilename((TUint8 *)file_name->get_data(file_name->get_data_length())); |
|
288 tmpFilename.SetLength(file_name->get_data_length()); |
|
289 |
|
290 EAP_TRACE_DATA_DEBUG( |
|
291 m_am_tools, |
|
292 TRACE_FLAGS_DEFAULT, |
|
293 (EAPL("Configure file"), |
|
294 tmpFilename.PtrZ(), |
|
295 tmpFilename.Length())); |
|
296 |
|
297 TBuf<EAP_MAX_FILENAME_LENGTH> filename; |
|
298 filename.Copy(tmpFilename); |
|
299 |
|
300 EAP_TRACE_DATA_DEBUG( |
|
301 m_am_tools, |
|
302 TRACE_FLAGS_DEFAULT, |
|
303 (EAPL("Configure file"), |
|
304 filename.PtrZ(), |
|
305 filename.Size())); |
|
306 |
|
307 TInt result = m_file_session.Connect(); |
|
308 if (result != KErrNone) |
|
309 { |
|
310 EAP_TRACE_ERROR(m_am_tools, |
|
311 TRACE_FLAGS_DEFAULT, |
|
312 (EAPL("ERROR: configuration file %s not found, error %d\n"), |
|
313 reinterpret_cast<char *>(file_name->get_data(file_name->get_data_length())), |
|
314 result)); |
|
315 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
316 return EAP_STATUS_RETURN(m_am_tools, eap_status_file_does_not_exist); |
|
317 } |
|
318 |
|
319 TUint aFileMode = EFileRead | EFileShareAny; |
|
320 if (dir == eap_file_io_direction_write) |
|
321 { |
|
322 aFileMode = EFileWrite; |
|
323 } |
|
324 |
|
325 TInt err = m_File.Open(m_file_session, filename, aFileMode); |
|
326 if (err != KErrNone) |
|
327 { |
|
328 if (aFileMode == EFileWrite) |
|
329 { |
|
330 // Try create a new file. |
|
331 err = m_File.Create(m_file_session, filename, aFileMode); |
|
332 } |
|
333 |
|
334 if (err != KErrNone) |
|
335 { |
|
336 EAP_TRACE_ERROR(m_am_tools, |
|
337 TRACE_FLAGS_DEFAULT, |
|
338 (EAPL("ERROR: configuration file %s not found, mode %d, error %d\n"), |
|
339 reinterpret_cast<char *>(file_name->get_data(file_name->get_data_length())), |
|
340 aFileMode, |
|
341 err)); |
|
342 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
343 return EAP_STATUS_RETURN(m_am_tools, eap_status_file_does_not_exist); |
|
344 } |
|
345 } |
|
346 |
|
347 m_input_buffer_offset = 0ul; |
|
348 |
|
349 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
350 return EAP_STATUS_RETURN(m_am_tools, eap_status_ok); |
|
351 } |
|
352 |
|
353 //---------------------------------------------------------------------------------------------------- |
|
354 |
|
355 /** |
|
356 * The function closes the file. |
|
357 */ |
|
358 EAP_FUNC_EXPORT eap_status_e eap_am_file_input_symbian_c::file_close() |
|
359 { |
|
360 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
361 |
|
362 m_File.Close(); |
|
363 m_file_session.Close(); |
|
364 |
|
365 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
366 return EAP_STATUS_RETURN(m_am_tools, eap_status_ok); |
|
367 } |
|
368 |
|
369 //---------------------------------------------------------------------------------------------------- |
|
370 |
|
371 /** |
|
372 * This function reads n bytes from file to buffer. |
|
373 */ |
|
374 eap_status_e eap_am_file_input_symbian_c::file_read_buffer( |
|
375 eap_variable_data_c * const buffer, |
|
376 const u32_t required_bytes) |
|
377 { |
|
378 u32_t read_bytes(0ul); |
|
379 |
|
380 eap_status_e status = buffer->set_data_length(0ul); |
|
381 if (status != eap_status_ok) |
|
382 { |
|
383 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
384 return EAP_STATUS_RETURN(m_am_tools, status); |
|
385 } |
|
386 |
|
387 bool file_end(false); |
|
388 |
|
389 while(file_end == false |
|
390 && read_bytes < required_bytes) |
|
391 { |
|
392 if (m_input_buffer->Length() == m_input_buffer_offset) |
|
393 { |
|
394 TInt ReadStatus = m_File.Read(*m_input_buffer, EAP_AM_FILE_INPUT_BUFFER_SIZE); |
|
395 if (ReadStatus != KErrNone |
|
396 || m_input_buffer->Length() == 0UL |
|
397 || m_input_buffer->Ptr() == 0) |
|
398 { |
|
399 file_end = true; |
|
400 } |
|
401 |
|
402 m_input_buffer_offset = 0ul; |
|
403 } |
|
404 |
|
405 const u8_t * const character = m_input_buffer->Ptr() + m_input_buffer_offset; |
|
406 if (character == 0) |
|
407 { |
|
408 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
409 return EAP_STATUS_RETURN(m_am_tools, eap_status_end_of_file); |
|
410 } |
|
411 |
|
412 u32_t copied_bytes = required_bytes - read_bytes; |
|
413 if (copied_bytes > (m_input_buffer->Length() - m_input_buffer_offset)) |
|
414 { |
|
415 copied_bytes = (m_input_buffer->Length() - m_input_buffer_offset); |
|
416 } |
|
417 |
|
418 status = buffer->add_data(character, copied_bytes); |
|
419 if (status != eap_status_ok) |
|
420 { |
|
421 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
422 return EAP_STATUS_RETURN(m_am_tools, status); |
|
423 } |
|
424 |
|
425 read_bytes += copied_bytes; |
|
426 m_input_buffer_offset += copied_bytes; |
|
427 |
|
428 } // while() |
|
429 |
|
430 if (file_end == true) |
|
431 { |
|
432 return EAP_STATUS_RETURN(m_am_tools, eap_status_end_of_file); |
|
433 } |
|
434 else |
|
435 { |
|
436 return EAP_STATUS_RETURN(m_am_tools, eap_status_ok); |
|
437 } |
|
438 } |
|
439 |
|
440 //---------------------------------------------------------------------------------------------------- |
|
441 |
|
442 /** |
|
443 * This function reads line from file. |
|
444 */ |
|
445 EAP_FUNC_EXPORT eap_status_e eap_am_file_input_symbian_c::file_read_line( |
|
446 eap_variable_data_c * const line) |
|
447 { |
|
448 if (line == 0 |
|
449 || line->get_is_valid() == false) |
|
450 { |
|
451 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
452 return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_parameter); |
|
453 } |
|
454 |
|
455 line->set_data_length(0ul); |
|
456 |
|
457 eap_variable_data_c buffer(m_am_tools); |
|
458 |
|
459 eap_status_e file_status(eap_status_ok); |
|
460 |
|
461 while (file_status == eap_status_ok) |
|
462 { |
|
463 file_status = file_read_buffer( |
|
464 &buffer, |
|
465 sizeof(u8_t)); |
|
466 if (file_status != eap_status_ok |
|
467 && file_status != eap_status_end_of_file) |
|
468 { |
|
469 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
470 return EAP_STATUS_RETURN(m_am_tools, file_status); |
|
471 } |
|
472 |
|
473 if (buffer.get_data_length() < sizeof(u8_t)) |
|
474 { |
|
475 file_status = EAP_STATUS_RETURN(m_am_tools, eap_status_end_of_file); |
|
476 break; |
|
477 } |
|
478 |
|
479 const u8_t * const character = buffer.get_data(sizeof(u8_t)); |
|
480 |
|
481 if (character == 0 |
|
482 || *character == '\n') |
|
483 { |
|
484 // This is the end of the line. |
|
485 break; |
|
486 } |
|
487 |
|
488 if (*character != '\r') // Windows files inludes these. |
|
489 { |
|
490 eap_status_e status = line->add_data(character, sizeof(*character)); |
|
491 if (status != eap_status_ok) |
|
492 { |
|
493 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
494 return EAP_STATUS_RETURN(m_am_tools, status); |
|
495 } |
|
496 } |
|
497 |
|
498 } // while() |
|
499 |
|
500 { |
|
501 eap_status_e add_status = line->add_end_null(); |
|
502 if (add_status != eap_status_ok) |
|
503 { |
|
504 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
505 return EAP_STATUS_RETURN(m_am_tools, add_status); |
|
506 } |
|
507 } |
|
508 |
|
509 // Note this should return the final file_status. |
|
510 return EAP_STATUS_RETURN(m_am_tools, file_status); |
|
511 } |
|
512 |
|
513 //---------------------------------------------------------------------------------------------------- |
|
514 |
|
515 /** |
|
516 * This function reads word from file. |
|
517 */ |
|
518 eap_status_e eap_am_file_input_symbian_c::file_read_word(eap_variable_data_c * const word) |
|
519 { |
|
520 if (word == 0 |
|
521 || word->get_is_valid() == false) |
|
522 { |
|
523 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
524 return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_parameter); |
|
525 } |
|
526 |
|
527 word->set_data_length(0ul); |
|
528 |
|
529 eap_variable_data_c buffer(m_am_tools); |
|
530 |
|
531 eap_status_e file_status(eap_status_ok); |
|
532 |
|
533 while (file_status == eap_status_ok) |
|
534 { |
|
535 file_status = file_read_buffer( |
|
536 &buffer, |
|
537 sizeof(u8_t)); |
|
538 if (file_status != eap_status_ok |
|
539 && file_status != eap_status_end_of_file) |
|
540 { |
|
541 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
542 return EAP_STATUS_RETURN(m_am_tools, file_status); |
|
543 } |
|
544 |
|
545 if (buffer.get_data_length() < sizeof(u8_t)) |
|
546 { |
|
547 file_status = EAP_STATUS_RETURN(m_am_tools, eap_status_end_of_file); |
|
548 break; |
|
549 } |
|
550 |
|
551 const u8_t * character = buffer.get_data(sizeof(u8_t)); |
|
552 |
|
553 if (character == 0 |
|
554 || m_am_tools->isspace(*character) |
|
555 || *character == ',') |
|
556 { |
|
557 break; |
|
558 } |
|
559 else if (*character == '#') |
|
560 { |
|
561 while (file_status == eap_status_ok) |
|
562 { |
|
563 file_status = file_read_buffer( |
|
564 &buffer, |
|
565 sizeof(u8_t)); |
|
566 if (file_status != eap_status_ok |
|
567 && file_status != eap_status_end_of_file) |
|
568 { |
|
569 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
570 return EAP_STATUS_RETURN(m_am_tools, file_status); |
|
571 } |
|
572 |
|
573 character = buffer.get_data(sizeof(u8_t)); |
|
574 |
|
575 if (character == 0 |
|
576 || *character == '\n') |
|
577 { |
|
578 break; |
|
579 } |
|
580 } |
|
581 } |
|
582 else |
|
583 { |
|
584 eap_status_e status = word->add_data(character, sizeof(*character)); |
|
585 if (status != eap_status_ok) |
|
586 { |
|
587 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
588 return EAP_STATUS_RETURN(m_am_tools, status); |
|
589 } |
|
590 } |
|
591 } // while() |
|
592 |
|
593 |
|
594 { |
|
595 eap_status_e add_status = word->add_end_null(); |
|
596 if (add_status != eap_status_ok) |
|
597 { |
|
598 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
599 return EAP_STATUS_RETURN(m_am_tools, add_status); |
|
600 } |
|
601 } |
|
602 |
|
603 |
|
604 // Note this should return the final file_status. |
|
605 return EAP_STATUS_RETURN(m_am_tools, file_status); |
|
606 } |
|
607 |
|
608 //---------------------------------------------------------------------------------------------------- |
|
609 |
|
610 /** |
|
611 * The set_is_valid() function sets the state of the object valid. |
|
612 * The creator of this object calls this function after it is initialized. |
|
613 */ |
|
614 void eap_am_file_input_symbian_c::set_is_valid() |
|
615 { |
|
616 m_is_valid = true; |
|
617 } |
|
618 |
|
619 //---------------------------------------------------------------------------------------------------- |
|
620 |
|
621 /** |
|
622 * Object must indicate it's validity. |
|
623 * If object initialization fails this function must return false. |
|
624 * @return This function returns the validity of this object. |
|
625 */ |
|
626 bool eap_am_file_input_symbian_c::get_is_valid() |
|
627 { |
|
628 return m_is_valid; |
|
629 } |
|
630 |
|
631 //---------------------------------------------------------------------------------------------------- |
|
632 |
|
633 eap_status_e eap_am_file_input_symbian_c::directory_open( |
|
634 const eap_variable_data_c * const /* directory_name */) |
|
635 { |
|
636 return EAP_STATUS_RETURN(m_am_tools, eap_status_not_supported); |
|
637 } |
|
638 |
|
639 //---------------------------------------------------------------------------------------------------- |
|
640 |
|
641 eap_status_e eap_am_file_input_symbian_c::directory_read( |
|
642 eap_array_c<abs_eap_file_stat_c> * const /* directory_list */) |
|
643 { |
|
644 return EAP_STATUS_RETURN(m_am_tools, eap_status_not_supported); |
|
645 } |
|
646 |
|
647 //---------------------------------------------------------------------------------------------------- |
|
648 |
|
649 /** |
|
650 * This function closes the directory. |
|
651 */ |
|
652 eap_status_e eap_am_file_input_symbian_c::directory_close() |
|
653 { |
|
654 return EAP_STATUS_RETURN(m_am_tools, eap_status_not_supported); |
|
655 } |
|
656 |
|
657 //---------------------------------------------------------------------------------------------------- |
|
658 |
|
659 abs_eap_am_file_input_c * abs_eap_am_file_input_c::new_abs_eap_am_file_input_c( |
|
660 abs_eap_am_tools_c * const tools) |
|
661 { |
|
662 abs_eap_am_file_input_c * const file_input = new eap_am_file_input_symbian_c(tools); |
|
663 |
|
664 if (file_input == 0 |
|
665 || file_input->get_is_valid() == false) |
|
666 { |
|
667 delete file_input; |
|
668 (void) EAP_STATUS_RETURN(tools, eap_status_allocation_error); |
|
669 return 0; |
|
670 } |
|
671 |
|
672 return file_input; |
|
673 } |
|
674 |
|
675 //---------------------------------------------------------------------------------------------------- |
|
676 |
|
677 // End. |