本文整理汇总了C++中Session::Daemon方法的典型用法代码示例。如果您正苦于以下问题:C++ Session::Daemon方法的具体用法?C++ Session::Daemon怎么用?C++ Session::Daemon使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Session
的用法示例。
在下文中一共展示了Session::Daemon方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: request
void
LaunchDaemon::_HandleGetLaunchTargets(BMessage* message)
{
uid_t user = _GetUserID(message);
if (user < 0)
return;
BMessage reply;
status_t status = B_OK;
if (!fUserMode) {
// Request the data from the user's daemon, too
Session* session = FindSession(user);
if (session != NULL) {
BMessage request(B_GET_LAUNCH_TARGETS);
status = request.AddInt32("user", 0);
if (status == B_OK) {
status = session->Daemon().SendMessage(&request,
&reply);
}
if (status == B_OK)
status = reply.what;
} else
status = B_NAME_NOT_FOUND;
}
if (status == B_OK) {
TargetMap::const_iterator iterator = fTargets.begin();
for (; iterator != fTargets.end(); iterator++)
reply.AddString("target", iterator->first);
}
reply.what = status;
message->SendReply(&reply);
}
示例2: reply
void
LaunchDaemon::_HandleStopLaunchJob(BMessage* message)
{
uid_t user = _GetUserID(message);
if (user < 0)
return;
const char* name = message->GetString("name");
Job* job = FindJob(name);
if (job == NULL) {
Session* session = FindSession(user);
if (session != NULL) {
// Forward request to user launch_daemon
if (session->Daemon().SendMessage(message) == B_OK)
return;
}
BMessage reply(B_NAME_NOT_FOUND);
message->SendReply(&reply);
return;
}
_StopJob(job, message->GetBool("force"));
BMessage reply((uint32)B_OK);
message->SendReply(&reply);
}
示例3: FindSession
void
LaunchDaemon::_ForwardEventMessage(uid_t user, BMessage* message)
{
if (fUserMode)
return;
// Forward event to user launch_daemon(s)
if (user == 0) {
for (SessionMap::iterator iterator = fSessions.begin();
iterator != fSessions.end(); iterator++) {
Session* session = iterator->second;
session->Daemon().SendMessage(message);
// ignore reply
}
} else {
Session* session = FindSession(user);
if (session != NULL)
session->Daemon().SendMessage(message);
}
}
示例4: reply
void
LaunchDaemon::_HandleGetLaunchData(BMessage* message)
{
uid_t user = _GetUserID(message);
if (user < 0)
return;
BMessage reply((uint32)B_OK);
bool launchJob = true;
Job* job = FindJob(get_leaf(message->GetString("name")));
if (job == NULL) {
Session* session = FindSession(user);
if (session != NULL) {
// Forward request to user launch_daemon
if (session->Daemon().SendMessage(message) == B_OK)
return;
}
reply.what = B_NAME_NOT_FOUND;
} else if (!job->IsLaunched()) {
if (job->InitCheck() == B_NO_INIT || !job->CheckCondition(*this)) {
// The job exists, but cannot be started yet, as its
// conditions are not met; don't make it available yet
// TODO: we may not want to initialize jobs with conditions
// that aren't met yet
reply.what = B_NO_INIT;
} else if (job->Event() != NULL) {
if (!Events::TriggerDemand(job->Event())) {
// The job is not triggered by demand; we cannot start it now
reply.what = B_NO_INIT;
} else {
// The job has already been triggered, don't launch it again
launchJob = false;
}
}
}
if (reply.what == B_OK) {
// If the job has not been launched yet, we'll pass on our
// team here. The rationale behind this is that this team
// will temporarily own the synchronous reply ports.
reply.AddInt32("team", job->Team() < 0
? current_team() : job->Team());
PortMap::const_iterator iterator = job->Ports().begin();
for (; iterator != job->Ports().end(); iterator++) {
BString name;
if (iterator->second.HasString("name"))
name << iterator->second.GetString("name") << "_";
name << "port";
reply.AddInt32(name.String(),
iterator->second.GetInt32("port", -1));
}
// Launch the job if it hasn't been launched already
if (launchJob)
_LaunchJob(job);
}
message->SendReply(&reply);
}