/*------------------------------------------------------------------------
 *
 *  File:	o1k_conf.h
 *  Revision:	1.14
 *  Last Mod:	17:36:49, 03/01/97
 *
 *  Description:
 *     Defines the O1kConf class for the o1k_conf example.
 *     
 *----------------------------------------------------------------------*/
#pragma ident	"@(#)o1k_conf.h	1.14\t97/03/01  "

#ifndef _O1K_CONF_H
#define _O1K_CONF_H

class O1kConf;

#include "o1k_defines.h"
#include "o1k_video.h"
#include "o1k_audio.h"
#include "o1k_network.h"
#include "o1k_ab.h"
#include "o1k_cntrl.h"

extern int verbose;
extern int register_trap;

/* These are the various conference states */
#define CONF_IDLE          0  /* no conference initiated              */
#define CONF_CALLING       1  /* user is calling a far end            */
#define CONF_RECEIVED_CALL 2  /* user has receive a call from far end */
#define CONF_JOINING       3  /* user is in process of joining        */
#define CONF_IN_CONF       4  /* user is in a active conference       */
#define CONF_CLOSING       5  /* user is in process of hanging up     */

/*------------------------------------------------------------------------
 *
 *  Class:	O1kConf
 *
 * Description:
 *     The O1kConf class contains the various objects that make
 *     up conference (these include the audio and video objects,
 *     the network object, and the address book object).
 *
 *     The user should call checkControl() in a loop or in some
 *     sort of timer callback. This routine will provide control
 *     information to the user.
 *
 *     For initiating a call, a user would first initialize the
 *     various conference objects and then call() a conference.
 *     The user would then call checkControl() waiting for the
 *     far end to respond. The call will either be accepted or
 *     timeout. The checkControl() routine will inform the user
 *     of this fact and the user should call callAccepted() or
 *     callTimedout().
 *     
 *     If idle and a far end call is detected, the checkControl()
 *     routine will return CNTRL_CALLING. The user can can then
 *     check the incoming_call CallInfo struct to determine if
 *     to deny or accept the call. The joinAccept() or joinDeny()
 *     should be called.
 *
 *     When in a conference, hangup() may be called to close the
 *     conference.
 *     
 *----------------------------------------------------------------------*/

class O1kConf {

public:
  CallInfo      incoming_call;
  
  int           state;
  Boolean       loop_mode;
  
  uid_t         user_id;
  char          user_name[40];
  char          host_name[40];
  char          userhost[80];

  struct timeval tstart;
  
  O1kVideo*     video;
  O1kAudio*     audio;
  O1kNetwork*   network;
  O1kAddrBook*  addressbook;
  
private:
  void setState(int s);
  void settings();
  
public:
  O1kConf();
  ~O1kConf();

  int  call();
  int  hangup();
  
  int  checkControl();
  int  callAccepted();
  int  callTimedout();
  int  joinAccept();
  int  joinDeny();
};

extern O1kConf* conf;

void o1k_conf_exit(int signo);

#endif
