2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
21 #include <sys/socket.h>
24 #include "bluetooth-api.h"
25 #include "bt-internal-types.h"
27 #include "bt-service-common.h"
28 #include "bt-service-event.h"
29 #include "bt-service-util.h"
30 #include "bt-service-rfcomm-client.h"
31 #include "bt-service-rfcomm-server.h"
32 #include "bt-service-agent.h"
34 /* Range of RFCOMM server ID : 0 ~ 244 */
35 #define BT_RFCOMM_SERVER_ID_MAX 245
37 #define BT_RFCOMM_PROXY_ADDRESS "x00/bluez/rfcomm"
38 #define BT_RFCOMM_SOCKET_ADDRESS "/bluez/rfcomm"
44 } bt_rfcomm_event_info_t;
47 bt_rfcomm_server_info_t *_bt_rfcomm_get_server_info_using_uuid(char *uuid)
50 bt_rfcomm_server_info_t *server_info;
52 retv_if(uuid == NULL, NULL);
54 for (l = server_list; l != NULL; l = l->next) {
55 server_info = l->data;
57 if (server_info == NULL)
60 if (g_strcmp0(server_info->uuid, uuid) == 0)
67 int _bt_rfcomm_create_socket(char *sender, char *uuid)
69 return BLUETOOTH_ERROR_INTERNAL;
72 int __bt_rfcomm_server_get_address(bt_rfcomm_server_info_t *server_info)
74 return BLUETOOTH_ERROR_NONE;
77 int _bt_rfcomm_listen(int socket_fd, int max_pending, gboolean is_native)
79 return BLUETOOTH_ERROR_NONE;
82 int _bt_rfcomm_remove_socket(int socket_fd)
84 return BLUETOOTH_ERROR_NONE;
87 int _bt_rfcomm_server_disconnect(int data_fd)
89 return BLUETOOTH_ERROR_NONE;
92 /* To support the BOT */
93 int _bt_rfcomm_is_uuid_available(char *uuid, gboolean *available)
95 return BLUETOOTH_ERROR_NONE;
98 /* To support the BOT */
99 int _bt_rfcomm_accept_connection(void)
102 if (!_bt_agent_reply_authorize(TRUE))
103 return BLUETOOTH_ERROR_INTERNAL;
106 return BLUETOOTH_ERROR_NONE;
109 /* To support the BOT */
110 int _bt_rfcomm_reject_connection(void)
113 if (!_bt_agent_reply_authorize(FALSE))
114 return BLUETOOTH_ERROR_INTERNAL;
117 return BLUETOOTH_ERROR_NONE;
120 int _bt_rfcomm_server_disconnect_all_connection(void)
123 bt_rfcomm_server_info_t *server_info;
125 for (l = server_list; l != NULL; l = l->next) {
126 server_info = l->data;
128 if (server_info == NULL)
131 _bt_rfcomm_disconnect(server_info->data_fd);
134 return BLUETOOTH_ERROR_NONE;
137 int _bt_rfcomm_server_check_existence(gboolean *existence)
139 BT_CHECK_PARAMETER(existence, return);
141 if (server_list && g_slist_length(server_list) > 0)
146 return BLUETOOTH_ERROR_NONE;
149 int _bt_rfcomm_server_check_termination(char *name)
152 bt_rfcomm_server_info_t *server_info;
154 BT_CHECK_PARAMETER(name, return);
156 for (l = server_list; l != NULL; l = l->next) {
157 server_info = l->data;
159 if (server_info == NULL)
162 if (g_strcmp0(server_info->sender, name) == 0)
163 _bt_rfcomm_remove_socket(server_info->control_fd);
167 return BLUETOOTH_ERROR_NONE;