comparison src/ui3/mfw/mfw_BtipsOpps.c @ 420:e8ddbb0837ed

src/ui3: initial import of TCS3/LoCosto BMI & MFW code
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 21 Jan 2018 03:09:00 +0000
parents
children
comparison
equal deleted inserted replaced
419:59143cd42ec7 420:e8ddbb0837ed
1 /* =========================================================
2 * Texas Instruments OMAP(TM) Platform Software
3 * (c) Copyright Texas Instruments, Incorporated. All Rights Reserved.
4 *
5 * Use of this software is controlled by the terms and conditions found
6 * in the license agreement under which this software has been supplied.
7 * ========================================================== */
8 /*
9 $Project name: Basic Bluetooth MMI
10 $Project code:
11 $Module: Bluetooth BMG MFW
12 $File: mfw_BtipsOpps.c
13 $Revision: 1.0
14 $Author: Texas Instruments
15 $Date: 26/06/07
16
17 ********************************************************************************
18
19 Description:
20
21 This module provides the BTIPS BMG APPlication functionality.
22
23 ********************************************************************************
24 $History: mfw_BtipsOpps.c
25
26 26/06/07 Sasken original version
27
28 $End
29
30 *******************************************************************************/
31
32
33
34
35 /*******************************************************************************
36
37 Include files
38
39 *******************************************************************************/
40
41 #define ENTITY_MFW
42 /* includes */
43
44 #include <string.h>
45
46 #if defined (NEW_FRAME)
47
48 #include "typedefs.h"
49 #include "vsi.h"
50 #include "pei.h"
51 #include "custom.h"
52 #include "gsm.h"
53 #include "prim.h"
54
55 #else
56
57 #include "STDDEFS.H"
58 #include "custom.h"
59 #include "gsm.h"
60 #include "vsi.h"
61
62 #endif
63
64 #ifdef FF_MMI_BTIPS_APP
65 #include "btl_bmg.h"
66
67 /* Macro for sending events to UI - meanwhile, trace message to PCO Viewer */
68 extern int vsi_o_state_ttrace ( const char * const format, ... );
69 #define UI_DISPLAY(s) vsi_o_state_ttrace s
70
71 #include "osapi.h"
72 #include "btl_common.h"
73 #include "debug.h"
74
75 #include "btl_opps.h"
76 #include "btl_config.h"
77 #include "bthal_config.h"
78 #include "bthal_fs.h"
79
80 #include "Mfw_mfw.h"
81 #include "Mfw_Btips.h"
82
83
84
85 /********************************************************************************
86 *
87 * Constants
88 *
89 *******************************************************************************/
90
91 #define OPPSA_DEFAULT_VCARD_NAME "mycard.vcf"
92 #define OPPSA_ACCEPT_DEFAULT_DIR "/MfwBtDemo"
93
94 #define OPPSA_DEFAULT_FULL_NAME "/MfwBtDemo/default/mycard.vcf"
95
96 #define OPPSA_SERVER_NAME "OBEX Object Push"
97
98 #define OPPSA_DEFAULT_FULL_DIR "/MfwBtDemo"
99
100 #define OPPSA_NEW_PUSH_NAME "pushed_file.vcf"//sundeep
101
102 #define OPPSA_PULL_USE_DEFAULT_OBJ (0x01)//sundeep
103 #define OPPSA_PULL_USE_NEW_OBJ (0x02)//sundeep
104 #define OPPSA_NEW_VCARD_NAME "mycard_t.vcf"
105 #define OPPSA_NEW_FULL_NAME "/QbInbox/default_object/mycard_t.vcf"
106 typedef U8 OppsaPullUseObject;
107
108 /*******************************************************************************
109 *
110 * Macro definitions
111 *
112 ******************************************************************************/
113 #define OPPSA_BUFF_MAX (1 * 512)
114
115
116 #define OPPSA_CHECK_OBJ_LOCATION(objectLocation) \
117 ((objectLocation == BTL_OBJECT_LOCATION_FS) || \
118 (objectLocation == BTL_OBJECT_LOCATION_MEM))
119 //sundeep
120 static char userPushFileName[BTHAL_FS_MAX_FILE_NAME_LENGTH + 1] = {'\0'};
121 static char userPushPath[BTHAL_FS_MAX_PATH_LENGTH + 1] = {'\0'};
122 static char userPushFsPath[BTHAL_FS_MAX_FILE_NAME_LENGTH + BTHAL_FS_MAX_PATH_LENGTH + 1] = {'\0'};
123
124
125 /*******************************************************************************
126 *
127 * OPP External Function prototypes
128 *
129 ******************************************************************************/
130 #if 1
131 void mfw_btips_oppsInit(void);
132 void mfw_btips_oppsDeinit(void);
133 void mfw_btips_opps_AbortServer(void);
134 void mfw_btips_opps_Disconnect(void);
135 void mfw_btips_opps_GetConnectedDevice(void);
136 BOOL mfw_btips_opps_GetSecurityLevel(void);
137 BOOL mfw_btips_opps_SetSecurityLevel(BtSecurityLevel level);
138 void mfw_btips_oppsAcceptObjectRequest(BOOL accept);
139 void OPPSA_SetObjLocation(BtlObjectLocation objLocation);
140 #endif
141
142
143 /*-------------------------------------------------------------------------------
144 * OppsaState type
145 *
146 * Defines the OPPS current state.
147 */
148 typedef U8 OppsaState;
149
150 #define OPPSA_IDLE 0x00 /* OBEX and Transport disconnected */
151 #define OPPSA_CONNECTING 0x01 /* OBEX connecting */
152 #define OPPSA_TP_CONNECTED 0x02 /* Transport connected */
153 #define OPPSA_CONNECTED 0x03 /* OBEX connected */
154 #define OPPSA_DISCONNECTING 0x04 /* OBEX disconnecting */
155 #define OPPSA_TP_DISCONNECTING 0x05 /* Transport disconnecting */
156 #define OPPSA_DISABLING 0x06 /* OBEX and Transport disabling */
157
158
159 typedef struct _OppsaData
160 {
161 OppsaState state;
162
163 BOOL isConnected;
164
165 BOOL operationOngoing;
166
167 BtSecurityLevel securityLevel;
168
169 OppsOperation serverOperation;
170
171 BtlObjectLocation objLocation;
172
173 /* Memory Objects */
174 char pushBuff[OPPSA_BUFF_MAX];
175 char pullBuff[OPPSA_BUFF_MAX];
176
177 } OppsaData;
178
179
180 /********************************************************************************
181 *
182 * Globals
183 *
184 *******************************************************************************/
185
186 static OppsaData oppServer;
187
188 static BtlOppsContext *oppsContext = 0;
189
190
191 /*******************************************************************************
192 *
193 * Internal Function prototypes
194 *
195 ******************************************************************************/
196 static void btips_oppsCallback(const BtlOppsEvent *Event);
197 static const char *mfw_btips_oppsGoepOpName(GoepOperation Op);
198 //static void mfw_btips_oppsSetDefaultObject(BtlObject *obj, const char *ObName, const char* fullPath);//sundeep
199 static void mfw_btips_oppsSetDefaultObject(BtlObject *obj, OppsaPullUseObject useObj);
200 static void mfw_btips_oppsSetToMemObject(BtlObject *obj, char *buff);
201 static void mfw_btips_oppsSetToFsObject(BtlObject *obj, char *userPushFileName, char *userPushPath);
202 static void mfw_btips_oppsCreateDefaultVCardFile(void);
203 BOOL mfw_btips_oppsGetConnectedDevice (BD_ADDR *bdAddr, U8 *name);
204 BOOL mfw_btips_OppsDisconnect ();
205
206 /*---------------------------------------------------------------------------
207 * mfw_btips_oppsInit
208 *---------------------------------------------------------------------------
209 *
210 * Synopsis: Initialize the OBEX server for the OPP application
211 * and the Object Store.
212 *
213 * Return: voidOppsaPullUseObject useObj
214 *
215 */
216 void mfw_btips_oppsInit(void)
217 {
218 BtStatus status;
219 BtlObject serverObject;
220
221 oppServer.securityLevel = BSL_NO_SECURITY;
222 oppServer.state = OPPSA_IDLE;
223 oppServer.isConnected = FALSE;
224 oppServer.operationOngoing = FALSE;
225 oppServer.objLocation = BTL_OBJECT_LOCATION_FS;
226
227 status = BTL_OPPS_Create((BtlAppHandle *)0, btips_oppsCallback, &oppServer.securityLevel, &oppsContext);
228 Report(("BTL_OPPS_Create() returned %s.",pBT_Status(status)));
229
230 mfw_btips_oppsCreateDefaultVCardFile();
231
232 //mfw_btips_oppsSetDefaultObject(&serverObject, OPPSA_DEFAULT_VCARD_NAME, OPPSA_DEFAULT_FULL_NAME);//sundeep
233 mfw_btips_oppsSetDefaultObject(&serverObject, OPPSA_PULL_USE_DEFAULT_OBJ);
234 status = BTL_OPPS_SetDefaultObject(&serverObject);
235 Report(("BTL_OPPS_SetDefaultObject() returned %s.",pBT_Status(status)));
236
237 status = BTL_OPPS_Enable(oppsContext, "OPPS Server", BTL_OPPS_SUPPORTED_FORMATS_ANY);
238 Report(("BTL_OPPS_Enable() returned %s.",pBT_Status(status)));
239 }
240
241
242 /*---------------------------------------------------------------------------
243 * mfw_btips_oppsDeinit
244 *---------------------------------------------------------------------------
245 *
246 * Synopsis: Deinitialize the OBEX Server protocol.
247 *
248 * Return: voidOPPSA_PULL_USE_DEFAULT_OBJ
249 *
250 */
251
252 void mfw_btips_oppsDeinit(void)
253 {
254 BtStatus status;
255
256 status = BTL_OPPS_Disable(oppsContext);
257
258 Report(("BTL_OPPS_Disable() returned %s.",pBT_Status(status)));
259
260 if (status == BT_STATUS_SUCCESS)
261 {
262 status = BTL_OPPS_Destroy(&oppsContext);
263
264 Report(("BTL_OPPS_Destroy() returned %s.", pBT_Status(status)));
265
266 oppServer.state = OPPSA_IDLE;
267 oppServer.isConnected = FALSE;
268 oppServer.operationOngoing = FALSE;
269 }
270 else
271 {
272 oppServer.state = OPPSA_DISABLING;
273 }
274 }
275
276
277 /*---------------------------------------------------------------------------
278 * mfw_btips_opps_AbortServer
279 *---------------------------------------------------------------------------
280 *
281 * Synopsis: Requests the current operation to be aborted.
282 *
283 * Return: void
284 *
285 */
286 void mfw_btips_opps_AbortServer(void)
287 {
288 BtStatus status;
289
290 if (oppServer.operationOngoing == TRUE)
291 {
292 status = BTL_OPPS_Abort(oppsContext, OBRC_CONFLICT);
293 Report(("BTL_OPPS_Abort() returned %s.",pBT_Status(status)));
294 }
295 else
296 {
297 Report(("mfw_btips_opps_AbortServer: No ongoing OPP operation!"));
298 }
299 }
300
301
302 /*---------------------------------------------------------------------------
303 * mfw_btips_opps_Disconnect
304 *---------------------------------------------------------------------------
305 *
306 * Synopsis: Disconnects
307 *
308 */
309 void mfw_btips_opps_Disconnect(void)
310 {
311 BtStatus status;
312
313 if (oppServer.isConnected == TRUE)
314 {
315 status = BTL_OPPS_Disconnect(oppsContext);
316 Report(("BTL_OPPS_Disconnect() returned %s.", pBT_Status(status)));
317 }
318 else
319 {
320 Report(("mfw_btips_opps_Disconnect: Server is not connected!"));
321 }
322 }
323
324
325
326
327 /*---------------------------------------------------------------------------
328 * mfw_btips_opps_SetSecurityLevel
329 *
330 * Synopsis: Set the OPP Server security level.
331 *
332 * Return: void
333 *
334 */
335 BOOL mfw_btips_opps_SetSecurityLevel(BtSecurityLevel level)
336 {
337 BtStatus status;
338 BtSecurityLevel securityLevel;
339 BOOL ret_val;
340
341 securityLevel = oppServer.securityLevel;
342
343 if (securityLevel & level)
344 {
345 securityLevel &= (~level);
346 ret_val = FALSE;
347 }
348 else
349 {
350 securityLevel |= level;
351 ret_val = TRUE;
352 }
353
354 status = BTL_OPPS_SetSecurityLevel(oppsContext, &securityLevel);
355
356 Report(("BTL_OPPS_SetSecurityLevel() returned %s.", pBT_Status(status)));
357
358 if (status == BT_STATUS_SUCCESS)
359 {
360 oppServer.securityLevel = securityLevel;
361 }
362
363 return ((status == BT_STATUS_SUCCESS) ? (ret_val) : (!ret_val));
364 }
365
366
367 /*---------------------------------------------------------------------------
368 * mfw_btips_opps_GetSecurityLevel
369 *---------------------------------------------------------------------------
370 *
371 * Synopsis: Gets security level for the given OPPC context.
372 *
373 * Return: TRUE if security level is ON, else FALSE.
374 *
375 */
376 BOOL mfw_btips_opps_GetSecurityLevel(void)
377 {
378 BtStatus status;
379 BtSecurityLevel securityLevel;
380
381 status = BTL_OPPS_GetSecurityLevel(oppsContext, &securityLevel);
382
383 Report(("BTL_OPPS_GetSecurityLevel() returned %s.",pBT_Status(status)));
384
385 switch (securityLevel)
386 {
387 case 0:
388 Report(("Security level: BSL_NO_SECURITY"));
389 break;
390 case 1:
391 Report(("Security level: BSL_AUTHENTICATION_IN"));
392 break;
393 case 2:
394 Report(("Security level: BSL_AUTHORIZATION_IN"));
395 break;
396 case 4:
397 Report(("Security level: BSL_ENCRYPTION_IN"));
398 break;
399 case 3:
400 Report(("Security level: BSL_AUTHENTICATION_IN"));
401 Report(("and BSL_AUTHORIZATION_IN"));
402 break;
403 case 5:
404 Report(("Security level: BSL_AUTHENTICATION_IN"));
405 Report(("and BSL_ENCRYPTION_IN"));
406 break;
407 case 6:
408 Report(("Security level: BSL_AUTHORIZATION_IN"));
409 Report(("and BSL_ENCRYPTION_IN"));
410 break;
411 case 7:
412 Report(("Security level: BSL_AUTHENTICATION_IN"));
413 Report(("and BSL_AUTHORIZATION_IN"));
414 Report(("and BSL_ENCRYPTION_IN"));
415 break;
416 default:
417 Report(("Error: Wrong security level"));
418 break;
419
420 }
421
422 return ((status == BT_STATUS_SUCCESS) ? (TRUE) : (FALSE));
423 }
424
425
426 /*---------------------------------------------------------------------------
427 * OPPSA_AcceptObjectRequest
428 *---------------------------------------------------------------------------
429 *
430 * Synopsis: Accept the pending object request.
431 *
432 * Return: void
433 *
434 */
435 void mfw_btips_oppsAcceptObjectRequest(BOOL accept)
436 {
437 BtStatus status;
438 BtlObject serverObject;
439
440 TRACE_FUNCTION_P1("mfw_btips_oppsAcceptObjectRequest - %d", accept);
441 if (TRUE != OPPSA_CHECK_OBJ_LOCATION(oppServer.objLocation))
442 {
443 Report(("OPPSA_AcceptObjectRequest: Invalid objectLocation"));
444 return;
445 }
446
447 if (accept == FALSE)
448 {
449 mfw_btips_oppsSetToFsObject(&serverObject, userPushFileName, OPPSA_ACCEPT_DEFAULT_DIR);
450
451 status = BTL_OPPS_AcceptObjectRequest(oppsContext, FALSE, &serverObject);
452
453 Report(("BTL_OPPS_AcceptObjectRequest() returned %s.", pBT_Status(status)));
454 }
455 else
456 {
457 if (oppServer.serverOperation == GOEP_OPER_PUSH)
458 {
459 if (oppServer.objLocation == BTL_OBJECT_LOCATION_MEM)
460 {
461 mfw_btips_oppsSetToMemObject(&serverObject, oppServer.pushBuff);
462 }
463 else if (oppServer.objLocation == BTL_OBJECT_LOCATION_FS)
464 {
465 mfw_btips_oppsSetToFsObject(&serverObject, userPushFileName, OPPSA_ACCEPT_DEFAULT_DIR);
466 }
467 }
468 else if (oppServer.serverOperation == GOEP_OPER_PULL)
469 {
470 if (oppServer.objLocation == BTL_OBJECT_LOCATION_MEM)
471 {
472 mfw_btips_oppsSetToMemObject(&serverObject, oppServer.pullBuff);
473 }
474 else if (oppServer.objLocation == BTL_OBJECT_LOCATION_FS)
475 {
476 mfw_btips_oppsSetToFsObject(&serverObject, userPushFileName, OPPSA_ACCEPT_DEFAULT_DIR);
477 }
478 }
479
480 status = BTL_OPPS_AcceptObjectRequest(oppsContext, accept, &serverObject);
481
482 Report(("BTL_OPPS_AcceptObjectRequest() returned %s.", pBT_Status(status)));
483 }
484 }
485
486
487 /*---------------------------------------------------------------------------
488 * OPPSA_SetObjLocation
489 *---------------------------------------------------------------------------
490 *
491 * Synopsis: Set the object Location (Memory or FS)
492 *
493 * Return: None
494 *
495 */
496 void OPPSA_SetObjLocation(BtlObjectLocation objLocation)
497 {
498 oppServer.objLocation = objLocation;
499 }
500
501
502 /*---------------------------------------------------------------------------
503 * btips_oppsCallback
504 *---------------------------------------------------------------------------
505 *
506 * Synopsis: This function processes OBEX server protocol events.
507 *
508 * Return: void
509 *
510 */
511 void btips_oppsCallback(const BtlOppsEvent *Event)
512 {
513 /* Local variables */
514 static BD_ADDR bdAddr;
515 char addr[BDADDR_NTOA_SIZE];
516 BtStatus status = BT_STATUS_FAILED;
517 BtlBmgDeviceRecord record;
518 T_BTIPS_MMI_IND btips_mmi_ind;
519
520 btips_mmi_ind.mfwBtipsEventType = MFW_BTIPS_OPPS_EVENT;
521
522 TRACE_EVENT_P1("btips_oppsCallback %d", Event->oppsEvent->event);
523 /* Save the GOEP operation for future use */
524 oppServer.serverOperation = Event->oppsEvent->oper;
525
526 switch (Event->oppsEvent->event)
527 {
528 case OPPS_EVENT_START:
529 TRACE_EVENT_P1("Server: Starting %s operation.", mfw_btips_oppsGoepOpName(Event->oppsEvent->oper));
530 oppServer.operationOngoing = TRUE;
531 break;
532
533 case OPPS_EVENT_COMPLETE:
534 TRACE_EVENT_P1("Server: %s operation complete.", mfw_btips_oppsGoepOpName(Event->oppsEvent->oper));
535 oppServer.operationOngoing = FALSE;
536 //#if 0
537 if (Event->oppsEvent ->oper == GOEP_OPER_PUSH)
538 {
539 btips_mmi_ind.data.oppsBtEvent.mfwOppsEventType = MFW_BTIPS_OPPS_PUSH_COMP_EVENT;
540 }
541 if(Event->oppsEvent ->oper == GOEP_OPER_PULL)
542 {
543 btips_mmi_ind.data.oppsBtEvent.mfwOppsEventType = MFW_BTIPS_OPPS_PULL_COMP_EVENT;
544 }
545 btipsNotifyMFW(&btips_mmi_ind);
546 #if 0
547 if (Event->oppsEvent ->oper == GOEP_OPER_DISCONNECT)
548 {
549 btips_mmi_ind.data.oppsBtEvent.mfwOppsEventType = MFW_BTIPS_OPPS_DISCONNECT_EVENT;
550 }
551 btipsNotifyMFW(&btips_mmi_ind);
552 #endif
553 break;
554
555 case OPPS_EVENT_ABORTED:
556 TRACE_EVENT_P1("Server: GOEP %s operation failed or aborted.", mfw_btips_oppsGoepOpName(Event->oppsEvent->oper));
557 oppServer.isConnected = FALSE;
558 oppServer.operationOngoing = FALSE;
559 oppServer.state = OPPSA_IDLE;
560 break;
561
562 case OPPS_EVENT_TP_CONNECTED:
563 BTL_OPPS_GetConnectedDevice(oppsContext, &bdAddr);
564 TRACE_EVENT_P1("Server: Transport Connection is up to %s.", bdaddr_ntoa(&bdAddr, addr));
565 oppServer.state = OPPSA_TP_CONNECTED;
566 oppServer.isConnected = TRUE;
567 break;
568
569 case OPPS_EVENT_TP_DISCONNECTED:
570 TRACE_EVENT("Server: Transport Connection has been disconnected.");
571 oppServer.isConnected = FALSE;
572 oppServer.operationOngoing = FALSE;
573 if (oppServer.state != OPPSA_DISABLING)
574 {
575 oppServer.state = OPPSA_IDLE;
576 }
577 break;
578
579 case OPPS_EVENT_OBJECT_PROGRESS:
580 TRACE_EVENT("OPPSA_Callback: progress bar ...");
581 break;
582
583 case OPPS_EVENT_OBJECT_REQUEST:
584 TRACE_EVENT_P1("Server: Incoming object request: %s operation.", mfw_btips_oppsGoepOpName(Event->oppsEvent->oper));
585 TRACE_EVENT_P3("Server: Name: %s, Type: %s, Size: %u.", Event->oppsEvent->info.request.name,
586 Event->oppsEvent->info.request.type, Event->oppsEvent->info.request.objectLen);
587 TRACE_EVENT("Server: Please accept or reject!");
588 status = BTL_BMG_DDB_FindRecord(bdAddr, &record);
589 Report(("BTL_BMG_DDB_FindRecord() returned %s.", pBT_Status(status)));
590 btips_mmi_ind.data.oppsBtEvent.mfwOppsEventType = Event->oppsEvent ->oper;
591 strcpy(btips_mmi_ind.data.oppsBtEvent.p.opps.deviceName, record.name);
592 strcpy(btips_mmi_ind.data.oppsBtEvent.p.opps.oppObjectName, Event ->oppsEvent->info.request.name);
593 #if 1
594 btipsNotifyMFW(&btips_mmi_ind);
595 #else
596 mfw_btips_oppsAcceptObjectRequest(TRUE);
597 #endif
598 break;
599
600 case OPPS_EVENT_DISABLED:
601 UI_DISPLAY(("Server: Receiving OPPS_EVENT_DISABLED."));
602 if (OPPSA_DISABLING == oppServer.state)
603 {
604 status = BTL_OPPS_Destroy(&oppsContext);
605 Report(("BTL_OPPS_Destroy() returned %s.", pBT_Status(status)));
606 }
607 oppServer.state = OPPSA_IDLE;
608 break;
609
610 default:
611 UI_DISPLAY(("Server: Unexpected event: %i", Event->oppsEvent->event));
612 break;
613
614 }
615 }
616
617 /*---------------------------------------------------------------------------
618 * mfw_btips_oppsCallback
619 *---------------------------------------------------------------------------
620 *
621 * Synopsis: This function processes OBEX server protocol events.
622 *
623 * Return: void
624 *
625 */
626 void mfw_btips_oppsCallback(T_BTIPS_MMI_IND *para)
627 {
628
629 MfwBtOppsEvent oopsBtEvent = para->data.oppsBtEvent;
630 TRACE_FUNCTION_P1("mfw_btips_oppsCallback %d", oopsBtEvent.mfwOppsEventType);
631
632 switch(oopsBtEvent.mfwOppsEventType)
633 {
634 case OPPS_OPER_PUSH:
635 mfw_btips_signal(E_BTIPS_OPPS_PUSH_EVENT, para);
636 break;
637
638 case OPPS_OPER_PULL:
639 mfw_btips_signal(E_BTIPS_OPPS_PULL_EVENT, para);
640 break;
641 //#if 0
642 case MFW_BTIPS_OPPS_PUSH_COMP_EVENT:
643 mfw_btips_signal(E_BTIPS_OPPS_PUSH_COMP_EVENT, para);
644 break;
645
646 case MFW_BTIPS_OPPS_PULL_COMP_EVENT:
647 mfw_btips_signal(E_BTIPS_OPPS_PULL_COMP_EVENT, para);
648 //#endif
649 }
650
651 }
652
653 /*---------------------------------------------------------------------------
654 * mfw_btips_oppsGoepOpName
655 *---------------------------------------------------------------------------
656 *
657 * Synopsis: Return a pointer to the name of the current operation.
658 *
659 * Return: ASCII String pointer.
660 *
661 */
662 static const char *mfw_btips_oppsGoepOpName(GoepOperation Op)
663 {
664 switch (Op)
665 {
666 case GOEP_OPER_PUSH:
667 return "Push";
668 case GOEP_OPER_PULL:
669 return "Pull";
670 case GOEP_OPER_CONNECT:
671 return "Connect";
672 case GOEP_OPER_DISCONNECT:
673 return "Disconnect";
674 case GOEP_OPER_ABORT:
675 return "Abort";
676 case GOEP_OPER_DELETE:
677 return "Delete";
678 case GOEP_OPER_SETFOLDER:
679 return "Set Folder";
680 }
681 return "Unknown";
682 }
683
684
685 /*---------------------------------------------------------------------------
686 * mfw_btips_oppsSetDefaultObject()
687 *
688 * Synopsis: Function for setting the OPPS default object.
689 *
690 * Return: void
691 *
692 */
693 //static void mfw_btips_oppsSetDefaultObject(BtlObject *obj, const char *ObName, const char* fullPath)
694 static void mfw_btips_oppsSetDefaultObject(BtlObject *obj, OppsaPullUseObject useObj)
695 {
696 switch (useObj)
697 {
698 case OPPSA_PULL_USE_DEFAULT_OBJ:
699 obj->objectName = (const BtlUtf8 *)OPPSA_DEFAULT_VCARD_NAME;
700 obj->location.fsLocation.fsPath = (const BtlUtf8 *)OPPSA_DEFAULT_FULL_NAME;
701 break;
702
703 case OPPSA_PULL_USE_NEW_OBJ:
704 obj->objectName = (const BtlUtf8 *)OPPSA_NEW_VCARD_NAME;
705 obj->location.fsLocation.fsPath = (const BtlUtf8 *)OPPSA_NEW_FULL_NAME;
706 break;
707 }
708 // obj->objectName = ObName;
709 //obj->location.fsLocation.fsPath = fullPath;
710
711 obj->objectMimeType = "text/x-vCard";
712 obj->objectLocation = oppServer.objLocation;
713 }
714
715 /*---------------------------------------------------------------------------
716 * mfw_btips_oppsSetToMemObject()
717 *
718 * Synopsis: Function for testing OPP from memory objects.
719 * Sets memory object fields prior to PULL operation
720 *
721 * Return: void
722 *
723 */
724 static void mfw_btips_oppsSetToMemObject(BtlObject *obj, char *buff)
725 {
726 obj->objectLocation = BTL_OBJECT_LOCATION_MEM;
727 obj->location.fsLocation.fsPath = NULL;
728 obj->location.memLocation.memAddr = buff;
729 obj->location.memLocation.size = OPPSA_BUFF_MAX;
730
731 obj->objectMimeType = NULL;
732 }
733
734 /*---------------------------------------------------------------------------
735 * mfw_btips_oppsSetToFsObject()
736 *
737 * Synopsis: Function for testing OPP from memory objects.
738 * Sets FS object
739 *
740 * Return: void
741 *
742 */
743 static void mfw_btips_oppsSetToFsObject(BtlObject *obj, char *userPushFileName, char *userPushPath)
744 {
745 U16 len;
746 /* ToDo: obj->objectName
747
748 [NULL]- pushed objects are saved in C:\QInbox location
749
750 ["defaultPushed.vcf"] - pushed objects are saved in C:\QInbox location,
751 and then rename to "defaultPushed.vcf" file.
752 */
753
754 //obj->objectName = "defaultPushed.vcf";
755 obj->objectName = NULL;
756 obj->objectMimeType = NULL;
757 obj->objectLocation = BTL_OBJECT_LOCATION_FS;
758 //obj->location.fsLocation.fsPath = OPPSA_ACCEPT_DEFAULT_DIR;
759 if (userPushFileName[0] == '\0')
760 {
761 OS_StrCpyUtf8(userPushFileName, (const char *)OPPSA_NEW_PUSH_NAME);
762 }
763
764 userPushFsPath[0] = '\0';
765 OS_StrCpyUtf8(userPushFsPath, userPushPath);
766 len = OS_StrLenUtf8(userPushFsPath);
767 userPushFsPath[len] = BTHAL_FS_PATH_DELIMITER;
768 userPushFsPath[++len] = '\0';
769 OS_StrCatUtf8(userPushFsPath, userPushFileName);
770
771 userPushFileName[0] = '\0';
772
773 obj->location.fsLocation.fsPath = (const BtlUtf8 *)userPushFsPath;
774 }
775
776 /*---------------------------------------------------------------------------
777 * OppsaUiCreateDefaultVCardFile
778 *---------------------------------------------------------------------------
779 *
780 * Synopsis: Creates the default VCard file
781 *
782 * Return: void.
783 *
784 */
785 static void mfw_btips_oppsCreateDefaultVCardFile(void)
786 {
787 static char content[] = "BEGIN:VCARD\nVERSION:2.1\nN:Adam;Smith\nFN:Adam Smith\nTEL;WORK;VOICE:erez972-76271234\nTEL;CELL:972-9-54-785345\n \
788 X-IRMC-LUID:0000000089112FB8F5ED98469F141223445D85EC0700651F055323C0104ABA16A3A82F42C81E000000D0841B0000B783C70B99B5BE4CAF782AB8DD188B6D0000DF0956010000\n \
789 END:VCARD";
790
791 BtFsStatus btFsStatus;
792 BthalFsFileDesc fp;
793 BTHAL_U32 pNumWritten;
794 BTHAL_INT nSize;
795
796 /* Creates / Overwrites the current default VCard file */
797
798 //BTHAL_FS_Remove(OPPSA_DEFAULT_FULL_NAME);
799 btFsStatus = BTHAL_FS_Open((const BTHAL_U8 *)OPPSA_DEFAULT_FULL_NAME,
800 BTHAL_FS_O_RDWR| BTHAL_FS_O_BINARY, (BthalFsFileDesc *)&fp);
801 if (BT_STATUS_HAL_FS_SUCCESS == btFsStatus)
802 {
803 BTHAL_FS_Close(fp);
804 return;
805 }
806 btFsStatus = BTHAL_FS_Open((const BTHAL_U8 *)OPPSA_DEFAULT_FULL_NAME,
807 BTHAL_FS_O_CREATE | BTHAL_FS_O_RDWR | BTHAL_FS_O_BINARY, /* Create file */
808 (BthalFsFileDesc *)&fp);
809 if (BT_STATUS_HAL_FS_SUCCESS != btFsStatus)
810 {
811 Report(("OppsaUiCreateDefaultVCardFile(): Error - could not create Default VCard file %s.", OPPSA_DEFAULT_FULL_NAME));
812 Report(("Make sure that %s directory exists !.", OPPSA_DEFAULT_FULL_DIR));
813 return;
814 }
815
816 nSize = OS_StrLen(content);
817
818 if (BT_STATUS_HAL_FS_SUCCESS == BTHAL_FS_Write(fp, (void*)content, nSize, &pNumWritten))
819 {
820 Report(("OppsaUiCreateDefaultVCardFile(): Default VCard file \"%s\" created successfully.", OPPSA_DEFAULT_FULL_NAME));
821 }
822 else
823 {
824 Report(("OppsaUiCreateDefaultVCardFile(): Error - Unable to create default VCard file."));
825 }
826
827
828 BTHAL_FS_Close(fp);
829
830 Report(("OppsaUiCreateDefaultVCardFile(): nSize = %d, pNumWritten = %d", nSize, pNumWritten));
831 }
832
833 /*******************************************************************************
834
835 $Function: mfw_btips_oppsGetConnectDevice
836
837 $Description: Returns the TRUE when succeeds
838 $Returns: TRUE or FALSE
839
840 $Arguments:
841
842 *******************************************************************************/
843
844 BOOL mfw_btips_oppsGetConnectedDevice (BD_ADDR *bdAddr, U8 *name)
845 {
846 BtStatus status;
847
848
849 status = BTL_OPPS_GetConnectedDevice (oppsContext, bdAddr);
850
851
852
853
854 if (status == BT_STATUS_SUCCESS)
855 {
856 mfw_btips_bmgGetDeviceName (bdAddr, name);
857 TRACE_FUNCTION_P1("mfw_btips_oppsGetConnectDevice OPPS name %s ",name);
858 return TRUE;
859 }
860 return FALSE;
861 }
862
863
864
865 #endif
866