Skip to content
client_daemon.cc 1.95 KiB
Newer Older
/*
  This file is part of SLS.
  Copyright (C) 2008 Sebastien LUTTRINGER <contact@seblu.net>

  SLS is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; version 2 of the License.

  SLS is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with SLS; if not, write to the Free Software
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
*/

#include "sls.hh"
#include "client_daemon.hh"
Seblu's avatar
Seblu committed
#include <unistd.h>

/*******************************************************************************
** Public methods
*******************************************************************************/

void Daemon::exec() {
  // send scripts
Seblu's avatar
Seblu committed
  send_script();

  // starting scripts
Seblu's avatar
Seblu committed
  while (1) {
    c_.sendln("STATUS");
    sleep(1);
  }

  c_.sendln("EXIT");
}


/*******************************************************************************
** Protected methods
*******************************************************************************/

/**
 * Constructor
 *
 * @param c Attached connection
 */
Daemon::Daemon(Connection &c) : Client(c) {}

/**
 * Check if login and pass are valid daemon
 * and register login and pass are logged in DB
 *
 * @param login user login
 * @param pass user pass
 *
 * @return if daemon is logged or not
 */
bool Daemon::trust(const char *login, const char *pass) {
  assert(login);
  assert(pass);

  // check login and password in DB

  // store username
  login_ = login;

  // register as logged in DB

Seblu's avatar
Seblu committed
  return true;
}

/**
 * Return public type of backend
 */
string Daemon::type() {
  return "Host";
}

/**
 * Send all script to daemon
 *
 */
void Daemon::send_script() {