/*
 * Gnophone: A client for the Asterisk PBX
 *
 * Copyright (C) 2000-2005, Digium, Inc.
 *
 * Written by Mark Spencer
 *
 * Linux/UNIX version distributed under the terms of
 * the GNU General Public License
 *
 * gnophone.h: Shared definitions and callback functions
 *
 */
 
#ifndef _GNOPHONE_H_
#define _GNOPHONE_H_

#define DONT_DEFINE_BROWSER

#include <gtk/gtk.h>
#include <gdk/gdk.h>
#include <gdk/gdkkeysyms.h>

#include "config.h"
#include "conversation.h"
#include "dialog.h"
#include "gui.h"
#include "htmlengine.h"
#include "md5.h"
#include "prefix.h"
#ifndef _TELCO_C_
#include "telco.h"
#endif
#include "iaxclient.h"

#include <arpa/inet.h>
#include <errno.h>
#include <fcntl.h>
#include <netdb.h>
#include <netinet/in.h>
#include <sys/signal.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>

#ifndef GTK_WINDOW_DIALOG
 #define GTK_WINDOW_DIALOG GDK_WINDOW_DIALOG
#endif

/*#define DEFAULT_DIR "/usr/share/gnophone" this needs to go away (binreloc)*/

#define STARTING_URL "http://www.gnophone.com/directory/"
#define DEFAULT_HOME_PAGE "http://www.gnophone.com/directory/"
#define DEFAULT_FIRST_USE_PAGE "http://www.gnophone.com/first/"
#define INTRODUCTORY_CALL "iax://gnophone.com/demo"
#define REGISTER_URL "http://www.gnophone.com/directory/createAccount.php"
#define SUPPORT_URL "http://www.gnophone.com/support/"
#define DEVELOPERS_URL "http://www.gnophone.com/developers/"
#define BUGS_URL "http://bugs.linux-support.net/login_page.php"
#define DEFAULT_IMAGE "/gnophone/images/gnophone.png"
#define NO_VIDEO_IMAGE "images/novideo.png"
#define TEMP_IMAGE "tmp_image.jpg"
#define DEFAULT_MODULE_LOCATION "/gnophone/modules"

#define GNOPHONE_CONFIG "gnophone.cfg"

#define VIDEO_WIDTH 160
#define VIDEO_HEIGHT 120

#define KEY \
	"This paragraph is Copyright (C) 2000-2005, Digium, Inc.  \
In order for your module to load, it must return this key via a function \
called \"key\".  Any code which includes this paragraph must be licensed under \
the GNU General Public License version 2 or later (at your option).   Linux \
Support Services, Inc. reserves the right to allow other parties to license \
this paragraph under other terms as well."

/* GUI stuff */
extern int link_pcid;
extern int init_gphx_subsystem(int *argc, char **argv[]);
extern int build_gui(void);
extern int run_gui(void);
extern int start_load_url(char *url);
extern char home_page[];
extern int show_video_control();
extern char *get_image_filename(void);
extern int stop_image(void *wv);
extern char *user_image_filename();
extern char *base_filename(char *filename);
extern int use_cam();
extern int start_camera();
extern void stop_camera();
extern int set_cam_output(void *wv);
extern int deliver_sound(int format, void *sound, int len);
extern int show_audio_control(void);
extern void show_call_win(void);
extern int launch_call(char *who, char *title, int tbd);
extern void iax_reg(void);
extern void image_callback(void);
extern void telco_prefs(void);
extern int is_phone_number(char *);
extern void send_my_image(int, char *);
extern void open_new_call(GtkWidget *w);
extern void open_new_url(GtkWidget *w);
extern void upgrade_start(GtkWidget *w);

/* Interfaces from upgrade.c */
extern void upgrade_start(GtkWidget *);

/* Interfaces from about.c */
extern void show_about();

/* Interfaces from utils.c */
#define IMAGE_BUTTON_TYPE_BUTTON 0
#define IMAGE_BUTTON_TYPE_TOGGLE 1

GtkWidget *image_button_new(GtkWidget *, int, char *, char **);

/* Interfaces from v4l.c */
extern void video_save_settings();
extern void video_load_settings();

/* Options */
extern int option_autoanswer;
extern int load_modules();

extern int video_options;

extern char my_callerid[32];

#define OPT_VIDEO_SEND_IMAGE				0x00001
#define OPT_VIDEO_SEND_IMAGE_PREANSWER			0x00002
#define OPT_VIDEO_ENABLE_VIDEO				0x00004	
#define OPT_VIDEO_IGNORE_IMAGE				0x00008
#define OPT_VIDEO_IGNORE_IMAGE_PREANSWER		0x00010


/* Real phones can do more than audio */
extern void digit_ready(char digit, int startok, int useurl);
extern void answer(void);
extern void hangup(void);

extern void (*other_loudness)(int val);

extern int audioc;

#define DEFAULT_SUPPRESSION 20.0

/* How to interpret a requested "location" */
extern int interpret_call(char *s);
/* How to interpret a call URI like iax:// and tel: */
extern int interpret_call_strict(char *s);
#endif /* _GNOPHONE_H_ */
