4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Hocheol Seo <hocheol.seo@samsung.com>
7 * Girishashok Joshi <girish.joshi@samsung.com>
8 * Chanyeol Park <chanyeol.park@samsung.com>
10 * Licensed under the Apache License, Version 2.0 (the "License");
11 * you may not use this file except in compliance with the License.
12 * You may obtain a copy of the License at
14 * http://www.apache.org/licenses/LICENSE-2.0
16 * Unless required by applicable law or agreed to in writing, software
17 * distributed under the License is distributed on an "AS IS" BASIS,
18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 * See the License for the specific language governing permissions and
20 * limitations under the License.
24 #include <dbus/dbus.h>
28 #include <sys/socket.h>
31 #include "bluetooth-api.h"
32 #include "bt-internal-types.h"
34 #include "bt-service-common.h"
35 #include "bt-service-event.h"
36 #include "bt-service-util.h"
37 #include "bt-service-rfcomm-client.h"
38 #include "bt-service-rfcomm-server.h"
39 #include "bt-service-agent.h"
41 /* Range of RFCOMM server ID : 0 ~ 244 */
42 #define BT_RFCOMM_SERVER_ID_MAX 245
44 #define BT_RFCOMM_PROXY_ADDRESS "x00/bluez/rfcomm"
45 #define BT_RFCOMM_SOCKET_ADDRESS "/bluez/rfcomm"
51 } bt_rfcomm_event_info_t;
54 bt_rfcomm_server_info_t *_bt_rfcomm_get_server_info_using_uuid(char *uuid)
57 bt_rfcomm_server_info_t *server_info;
59 retv_if(uuid == NULL, NULL);
61 for (l = server_list; l != NULL; l = l->next) {
62 server_info = l->data;
64 if (server_info == NULL)
67 if (g_strcmp0(server_info->uuid, uuid) == 0)
74 int _bt_rfcomm_create_socket(char *sender, char *uuid)
76 return BLUETOOTH_ERROR_INTERNAL;
79 int __bt_rfcomm_server_get_address(bt_rfcomm_server_info_t *server_info)
81 return BLUETOOTH_ERROR_NONE;
84 int _bt_rfcomm_listen(int socket_fd, int max_pending, gboolean is_native)
86 return BLUETOOTH_ERROR_NONE;
89 int _bt_rfcomm_remove_socket(int socket_fd)
91 return BLUETOOTH_ERROR_NONE;
94 int _bt_rfcomm_server_disconnect(int data_fd)
96 return BLUETOOTH_ERROR_NONE;
99 /* To support the BOT */
100 int _bt_rfcomm_is_uuid_available(char *uuid, gboolean *available)
102 return BLUETOOTH_ERROR_NONE;
105 /* To support the BOT */
106 int _bt_rfcomm_accept_connection(void)
109 if (!_bt_agent_reply_authorize(TRUE))
110 return BLUETOOTH_ERROR_INTERNAL;
113 return BLUETOOTH_ERROR_NONE;
116 /* To support the BOT */
117 int _bt_rfcomm_reject_connection(void)
120 if (!_bt_agent_reply_authorize(FALSE))
121 return BLUETOOTH_ERROR_INTERNAL;
124 return BLUETOOTH_ERROR_NONE;
127 int _bt_rfcomm_server_disconnect_all_connection(void)
130 bt_rfcomm_server_info_t *server_info;
132 for (l = server_list; l != NULL; l = l->next) {
133 server_info = l->data;
135 if (server_info == NULL)
138 _bt_rfcomm_disconnect(server_info->data_fd);
141 return BLUETOOTH_ERROR_NONE;
144 int _bt_rfcomm_server_check_existence(gboolean *existence)
146 BT_CHECK_PARAMETER(existence, return);
148 if (server_list && g_slist_length(server_list) > 0) {
154 return BLUETOOTH_ERROR_NONE;
157 int _bt_rfcomm_server_check_termination(char *name)
160 bt_rfcomm_server_info_t *server_info;
162 BT_CHECK_PARAMETER(name, return);
164 for (l = server_list; l != NULL; l = l->next) {
165 server_info = l->data;
167 if (server_info == NULL)
170 if (g_strcmp0(server_info->sender, name) == 0) {
171 _bt_rfcomm_remove_socket(server_info->control_fd);
175 return BLUETOOTH_ERROR_NONE;