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

#ifndef _O1K_AB_H
#define _O1K_AB_H

/* The address book list canbe sorted in these ways */
typedef enum _SortType { SORT_USER, SORT_FIRST, SORT_LAST, SORT_EMAIL}  SortType;

#define O1K_DB_NAME_LEN   120
#define O1K_AB_MAX_STRING 120

class O1kUserList;
class O1kUserNode;

/* address book */

/*------------------------------------------------------------------------
 *
 *  Class:	O1kAddrBook
 *
 * Description:
 *     The O1kAddrBook object contains a list of info about
 *     users. This info includes a user's first and last name,
 *     their email address, telephone number and target 
 *     user@host name. The list is store in a database file
 *     in the main users home dir. The list can be loaded,
 *     stored, and sorted. Users in the list can be added
 *     and deleted.
 *
 *     The  setuser() routine is used to set the user name
 *     of the address book. This name is used for open and
 *     close of the address book db file located in
 *     /home/user_name/. The database file is called
 *     .o1k_conf_db. If setuser() is not called, the
 *     location of the db will be the current working dir.
 *     The env var O1K_CONF_DB can be used to override both
 *     of these settings and can be used as the location for
 *     the address book database.
 *
 *     The routines getFirstUser() and getNextUser() can be used
 *     to cycle through the list. The routine getUserInfo() will
 *     return user info.
 *
 *----------------------------------------------------------------------*/

class O1kAddrBook {

private:  
  O1kUserList* users;
  char         db_name[O1K_DB_NAME_LEN];
  SortType     cur_sort;
  
  void storeuser(O1kUserNode* unp);
  
public:
  O1kAddrBook();
  ~O1kAddrBook();

  void setuser(char* name);
  void sort(SortType s_type);
  void load();
  void store();
  void add_user(char* f, char* l, char* e, char* p, char* u);
  void delete_user(SortType s_type, char* s);

  SortType getSort() const { return cur_sort; }

  O1kUserNode* getUser(SortType s_type, char* s);
  O1kUserNode* getFirstUser();
  O1kUserNode* getNextUser(O1kUserNode* unp);
  
  void getUserInfo(O1kUserNode* unp, char* f, char* l, char* e, char* p, char* u);
  void getUserInfo(SortType s_type, char* s, char* f, char* l, char* e, char* p, char* u);
};

#endif
