const char *filename,
GError **error);
+static gboolean bluetooth_pb_destroy_agent(BluetoothPbAgent *agent,
+ DBusGMethodInvocation *context);
+
static void __bluetooth_pb_dbus_return_error(DBusGMethodInvocation *context,
gint code,
const gchar *message);
status = contacts_db_get_records_with_query(query, offset, limit, &record_list);
if (status != CONTACTS_ERROR_NONE) {
+ contacts_list_destroy(record_list, TRUE);
contacts_query_destroy(query);
return;
}
status = contacts_db_get_records_with_query(query,
-1, -1, &record_list);
- if (status != CONTACTS_ERROR_NONE)
+ if (status != CONTACTS_ERROR_NONE) {
+ contacts_list_destroy(record_list, TRUE);
return;
+ }
status = contacts_list_first(record_list);
status = contacts_db_get_records_with_query(query,
-1, -1, &record_list);
- if (status != CONTACTS_ERROR_NONE)
+ if (status != CONTACTS_ERROR_NONE) {
+ contacts_list_destroy(record_list, TRUE);
return;
+ }
status = contacts_list_first(record_list);
from - 1 , offset,
&record_list);
- if (status != CONTACTS_ERROR_NONE)
+ if (status != CONTACTS_ERROR_NONE) {
+ contacts_list_destroy(record_list, TRUE);
return;
+ }
status = contacts_list_first(record_list);
from - 1 , offset,
&record_list);
- if (status != CONTACTS_ERROR_NONE)
+ if (status != CONTACTS_ERROR_NONE) {
+ contacts_list_destroy(record_list, TRUE);
return;
+ }
status = contacts_list_first(record_list);
if (status != CONTACTS_ERROR_NONE) {
status = contacts_db_get_records_with_query(query,
-1, -1, &record_list);
- if (status != CONTACTS_ERROR_NONE)
+ if (status != CONTACTS_ERROR_NONE) {
+ contacts_list_destroy(record_list, TRUE);
return;
+ }
status = contacts_list_first(record_list);
i++;
} while (contacts_list_next(record_list) == CONTACTS_ERROR_NONE);
+ contacts_list_destroy(record_list, TRUE);
}
static void __bluetooth_pb_get_phone_log_list_name(BluetoothPbAgent *agent,
-1, -1,
&record_list);
- if (status != CONTACTS_ERROR_NONE)
+ if (status != CONTACTS_ERROR_NONE) {
+ contacts_list_destroy(record_list, TRUE);
return;
+ }
status = contacts_list_first(record_list);
static void __bluetooth_pb_agent_signal_handler(int signum)
{
- if (mainloop)
+ if (mainloop) {
g_main_loop_quit(mainloop);
- else
+ } else {
+ DBG("Terminate Bluetooth PBAP agent");
exit(0);
+ }
}
G_OBJECT(agent));
}
-int main(int argc, char **argv)
+static gboolean bluetooth_pb_destroy_agent(BluetoothPbAgent *agent,
+ DBusGMethodInvocation *context)
+{
+ g_main_loop_quit(mainloop);
+}
+
+int main(void)
{
BluetoothPbAgent *agent;
gint tapi_result;
struct sigaction sa;
+ DBG("Starting Bluetooth PBAP agent");
g_type_init();
g_main_loop_run(mainloop);
- DBG("Terminate the bluetooth-pb-agent\n");
-
- if (agent) {
- contacts_db_remove_changed_cb(_contacts_event._uri,
- __bluetooth_pb_contact_changed,
- g_object_ref(agent));
-
- g_object_unref(agent);
+ if (contacts_db_remove_changed_cb(_contacts_event._uri,
+ __bluetooth_pb_contact_changed,
+ g_object_ref(agent)) != CONTACTS_ERROR_NONE) {
+ DBG("Cannot remove changed callback");
}
+ g_object_unref(agent);
- contacts_disconnect2();
+ if (contacts_disconnect2() != CONTACTS_ERROR_NONE)
+ DBG("contacts_disconnect2 failed \n");
g_signal_emit(agent, signals[CLEAR], 0);
- if (agent)
- g_object_unref(agent);
+ g_object_unref(agent);
+ DBG("Terminate Bluetooth PBAP agent");
return ret;
}