Home | History | Annotate | Download | only in src

Lines Matching refs:agent

47 #include "agent.h"
60 struct agent {
74 struct agent *agent;
87 static void agent_release(struct agent *agent)
91 DBG("Releasing agent %s, %s", agent->name, agent->path);
93 if (agent->request)
94 agent_cancel(agent);
96 message = dbus_message_new_method_call(agent->name, agent->path,
97 "org.bluez.Agent", "Release");
110 DBG("Sending Cancel request to %s, %s", req->agent->name,
111 req->agent->path);
113 message = dbus_message_new_method_call(req->agent->name, req->agent->path,
114 "org.bluez.Agent", "Cancel");
131 if (req->agent && req->agent->request)
132 req->agent->request = NULL;
140 struct agent *agent = user_data;
142 DBG("Agent exited without calling Unregister");
144 agent->exited = TRUE;
146 agent_free(agent);
149 void agent_free(struct agent *agent)
151 if (!agent)
154 if (agent->remove_cb)
155 agent->remove_cb(agent, agent->remove_cb_data);
157 if (agent->request) {
165 switch (agent->request->type) {
167 pincode_cb = agent->request->cb;
168 pincode_cb(agent, &err, NULL, agent->request->user_data);
171 cb = agent->request->cb;
172 cb(agent, &err, agent->request->user_data);
177 agent_cancel(agent);
180 if (!agent->exited) {
181 g_dbus_remove_watch(connection, agent->listener_id);
182 agent_release(agent);
185 g_free(agent->name);
186 g_free(agent->path);
188 g_free(agent);
191 struct agent *agent_create(struct btd_adapter *adapter, const char *name,
195 struct agent *agent;
197 agent = g_new0(struct agent, 1);
199 agent->adapter = adapter;
200 agent->name = g_strdup(name);
201 agent->path = g_strdup(path);
202 agent->capability = capability;
203 agent->remove_cb = cb;
204 agent->remove_cb_data = remove_cb_data;
206 agent->listener_id = g_dbus_add_disconnect_watch(connection, name,
207 agent_exited, agent,
210 return agent;
213 static struct agent_request *agent_request_new(struct agent *agent,
223 req->agent = agent;
232 int agent_cancel(struct agent *agent)
234 if (!agent->request)
237 if (agent->request->call)
238 dbus_pending_call_cancel(agent->request->call);
240 if (!agent->exited)
241 send_cancel_request(agent->request);
243 agent_request_free(agent->request, TRUE);
244 agent->request = NULL;
252 struct agent *agent = req->agent;
270 error("Agent replied with an error: %s, %s",
273 cb(agent, &err, req->user_data);
276 agent_cancel(agent);
289 cb(agent, &err, req->user_data);
294 cb(agent, NULL, req->user_data);
298 agent->request = NULL;
306 struct agent *agent = req->agent;
308 req->msg = dbus_message_new_method_call(agent->name, agent->path,
309 "org.bluez.Agent", "Authorize");
330 int agent_authorize(struct agent *agent,
340 if (agent->request)
343 req = agent_request_new(agent, AGENT_REQUEST_AUTHORIZE, cb,
352 agent->request = req;
362 struct agent *agent = req->agent;
363 struct btd_adapter *adapter = agent->adapter;
386 error("Agent replied with an error: %s, %s",
389 cb(agent, &err, NULL, req->user_data);
399 cb(agent, &err, NULL, req->user_data);
408 error("Invalid PIN length (%zu) from agent", len);
411 cb(agent, &err, NULL, req->user_data);
416 cb(agent, NULL, pin, req->user_data);
423 agent->request = NULL;
430 struct agent *agent = req->agent;
432 req->msg = dbus_message_new_method_call(agent->name, agent->path,
433 "org.bluez.Agent", "RequestPinCode");
452 int agent_request_pincode(struct agent *agent, struct btd_device *device,
460 if (agent->request)
463 req = agent_request_new(agent, AGENT_REQUEST_PINCODE, cb,
470 agent->request = req;
482 struct agent *agent = req->agent;
484 req->msg = dbus_message_new_method_call(agent->name, agent->path,
485 "org.bluez.Agent", "ConfirmModeChange");
505 int agent_confirm_mode_change(struct agent *agent, const char *new_mode,
512 if (agent->request)
515 DBG("Calling Agent.ConfirmModeChange: name=%s, path=%s, mode=%s",
516 agent->name, agent->path, new_mode);
518 req = agent_request_new(agent, AGENT_REQUEST_CONFIRM_MODE,
525 agent->request = req;
537 struct agent *agent = req->agent;
556 error("Agent replied with an error: %s, %s",
558 cb(agent, &err, 0, req->user_data);
568 cb(agent, &err, 0, req->user_data);
573 cb(agent, NULL, passkey, req->user_data);
580 agent->request = NULL;
587 struct agent *agent = req->agent;
589 req->msg = dbus_message_new_method_call(agent->name, agent->path,
590 "org.bluez.Agent", "RequestPasskey");
609 int agent_request_passkey(struct agent *agent, struct btd_device *device,
617 if (agent->request)
620 DBG("Calling Agent.RequestPasskey: name=%s, path=%s",
621 agent->name, agent->path);
623 req = agent_request_new(agent, AGENT_REQUEST_PASSKEY, cb,
630 agent->request = req;
643 struct agent *agent = req->agent;
645 req->msg = dbus_message_new_method_call(agent->name, agent->path,
646 "org.bluez.Agent", "RequestConfirmation");
668 int agent_request_confirmation(struct agent *agent, struct btd_device *device,
676 if (agent->request)
679 DBG("Calling Agent.RequestConfirmation: name=%s, path=%s, passkey=%06u",
680 agent->name, agent->path, passkey);
682 req = agent_request_new(agent, AGENT_REQUEST_CONFIRMATION, cb,
689 agent->request = req;
701 struct agent *agent = req->agent;
703 req->msg = dbus_message_new_method_call(agent->name, agent->path,
704 "org.bluez.Agent", "RequestPairingConsent");
725 int agent_request_pairing_consent(struct agent *agent, struct btd_device *device,
733 if (agent->request)
736 DBG("Calling Agent.RequestPairingConsent: name=%s, path=%s",
737 agent->name, agent->path);
739 req = agent_request_new(agent, AGENT_REQUEST_PAIRING_CONSENT, cb,
746 agent->request = req;
758 struct btd_adapter *adapter = req->agent->adapter;
759 struct agent *adapter_agent = adapter_get_agent(adapter);
762 if (req->agent == adapter_agent || adapter_agent == NULL)
780 req->agent->request = NULL;
781 req->agent = adapter_agent;
782 req->agent->request = req;
792 int agent_display_passkey(struct agent *agent, struct btd_device *device,
798 message = dbus_message_new_method_call(agent->name, agent->path,
799 "org.bluez.Agent", "DisplayPasskey");
819 uint8_t agent_get_io_capability(struct agent *agent)
821 return agent->capability;
824 gboolean agent_matches(struct agent *agent, const char *name, const char *path)
826 if (g_str_equal(agent->name, name) && g_str_equal(agent->path, path))
832 gboolean agent_is_busy(struct agent *agent, void *user_data)
834 if (!agent->request)
837 if (user_data && user_data != agent->request->user_data)