Esempio n. 1
0
void AutoAwayPlugin::timeout()
{
    unsigned idle_time = getIdleTime();
    if ((bAway && getEnableAway() && (idle_time < getAwayTime() * 60)) ||
            (bNA && getEnableNA() && (idle_time < getNATime() * 60))){
        bAway = false;
        bNA   = false;
        for (unsigned i = 0; i < getContacts()->nClients(); i++){
            Client *client = getContacts()->getClient(i);
            if (!client->getCommonStatus())
                continue;
            client->setStatus(oldStatus, true);
        }
        core->setManualStatus(oldStatus);
        Event e(EventClientStatus);
        e.process();
        return;
    }
    if (!bAway && !bNA && getEnableAway() && (idle_time > getAwayTime() * 60)){
        unsigned i;
        unsigned long status = core->getManualStatus();
        if ((status == STATUS_AWAY) || (status == STATUS_NA) || (status == STATUS_OFFLINE))
            return;
        oldStatus = status;
        bAway = true;
        for (i = 0; i < getContacts()->nClients(); i++){
            Client *client = getContacts()->getClient(i);
            if (!client->getCommonStatus())
                continue;
            client->setStatus(STATUS_AWAY, true);
        }
        core->setManualStatus(STATUS_AWAY);
        Event e(EventClientStatus);
        e.process();
        return;
    }
    if (!bNA && getEnableNA() && (idle_time > getNATime() * 60)){
        unsigned i;
        unsigned long status = core->getManualStatus();
        if ((status == STATUS_NA) || (status == STATUS_OFFLINE))
            return;
        if (!bAway)
            oldStatus = status;
        bNA = true;
        for (i = 0; i < getContacts()->nClients(); i++){
            Client *client = getContacts()->getClient(i);
            if (!client->getCommonStatus())
                continue;
            client->setStatus(STATUS_NA, true);
        }
        core->setManualStatus(STATUS_NA);
        Event e(EventClientStatus);
        e.process();
        return;
    }
}
Esempio n. 2
0
void AutoAwayPlugin::timeout()
{
    unsigned long newStatus = core->getManualStatus();
    unsigned idle_time = getIdleTime() / 60;
    if ((bAway && (idle_time < getAwayTime())) ||
            (bNA && (idle_time < getNATime())) ||
            (bOff && (idle_time < getOffTime()))){
        bAway = false;
        bNA   = false;
        bOff  = false;
        newStatus = oldStatus;
    }else if (!bAway && !bNA && !bOff && getEnableAway() && (idle_time >= getAwayTime())){
        unsigned long status = core->getManualStatus();
        if ((status == STATUS_AWAY) || (status == STATUS_NA) || (status == STATUS_OFFLINE))
            return;
        oldStatus = status;
        newStatus = STATUS_AWAY;
        bAway = true;
    }else  if (!bNA && !bOff && getEnableNA() && (idle_time >= getNATime())){
        unsigned long status = core->getManualStatus();
        if ((status == STATUS_NA) || (status == STATUS_OFFLINE))
            return;
        if (!bAway)
            oldStatus = status;
        bNA = true;
        newStatus = STATUS_NA;
    }else if (!bOff && getEnableOff() && (idle_time >= getOffTime())){
        unsigned long status = core->getManualStatus();
        if (status == STATUS_OFFLINE)
            return;
        if (!bNA)
            oldStatus = status;
        bOff = true;
        newStatus = STATUS_OFFLINE;
    }
    if (newStatus == core->getManualStatus())
        return;
    for (unsigned i = 0; i < getContacts()->nClients(); i++){
        Client *client = getContacts()->getClient(i);
        if (!client->getCommonStatus())
            continue;
        client->setStatus(newStatus, true);
    }
    if (core->getManualStatus() == newStatus)
        return;
    time_t now;
    time(&now);
    core->data.StatusTime.value = now;
    core->data.ManualStatus.value = newStatus;
    Event e(EventClientStatus);
    e.process();
}