Desktop

/* $Id: gsm.h,v 1.70.2.9 2011/01/22 23:40:14 khorben Exp $ */
/* Copyright (c) 2011 Pierre Pronchery <khorben@defora.org> */
/* This file is part of DeforaOS Desktop Phone */
/* This program 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 3 of the License.
*
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>. */
#ifndef PHONE_GSM_H
# define PHONE_GSM_H
# include <glib.h>
# include "modem.h"
/* GSM */
/* types */
typedef struct _GSM GSM;
typedef enum _GSMBatteryStatus
{
GSM_BATTERY_STATUS_POWERED = 0,
GSM_BATTERY_STATUS_NOT_POWERED = 1,
GSM_BATTERY_STATUS_NO_BATTERY = 2,
GSM_BATTERY_STATUS_POWER_FAULT = 3
} GSMBatteryStatus;
typedef enum _GSMCallType
{
GSM_CALL_TYPE_UNKNOWN = 0,
GSM_CALL_TYPE_DATA,
GSM_CALL_TYPE_VOICE
} GSMCallType;
typedef struct _GSMCommand GSMCommand;
typedef void (*GSMCommandCallback)(GSM * gsm);
typedef enum _GSMEncoding
{
GSM_ENCODING_UTF8 = 0,
GSM_ENCODING_RAW_DATA
} GSMEncoding;
typedef enum _GSMError
{
GSM_ERROR_UNKNOWN = 0,
GSM_ERROR_ANSWER_FAILED,
GSM_ERROR_BATTERY_CHARGE_FAILED,
GSM_ERROR_BUSY,
GSM_ERROR_CALL_FAILED,
GSM_ERROR_CALL_WAITING_FAILED,
GSM_ERROR_CONTACT_DELETE_FAILED,
GSM_ERROR_CONTACT_EDIT_FAILED,
GSM_ERROR_CONTACT_FETCH_FAILED,
GSM_ERROR_CONTACT_LIST_FAILED,
GSM_ERROR_CONTACT_NEW_FAILED,
GSM_ERROR_HANGUP_FAILED,
GSM_ERROR_MESSAGE_DELETE_FAILED,
GSM_ERROR_MESSAGE_FETCH_FAILED,
GSM_ERROR_MESSAGE_LIST_FAILED,
GSM_ERROR_MESSAGE_SEND_FAILED,
GSM_ERROR_MUTE_FAILED,
GSM_ERROR_NO_ANSWER,
GSM_ERROR_NO_CARRIER,
GSM_ERROR_NO_DIALTONE,
GSM_ERROR_OPERATOR_MODE_FAILED,
GSM_ERROR_REJECT_FAILED,
GSM_ERROR_RESET_FAILED,
GSM_ERROR_SIGNAL_LEVEL_FAILED,
GSM_ERROR_SIM_PIN_REQUIRED,
GSM_ERROR_SIM_PIN_WRONG
} GSMError;
typedef enum _GSMMessageFormat
{
GSM_MESSAGE_FORMAT_PDU = 0,
GSM_MESSAGE_FORMAT_TEXT = 1
} GSMMessageFormat;
typedef enum _GSMMessageList
{
GSM_MESSAGE_LIST_UNREAD = 0,
GSM_MESSAGE_LIST_READ = 1,
GSM_MESSAGE_LIST_UNSENT = 2,
GSM_MESSAGE_LIST_SENT = 3,
GSM_MESSAGE_LIST_ALL = 4
} GSMMessageList;
typedef enum _GSMMessageMode
{
GSM_MESSAGE_MODE_BUFFER_REPLACE = 0,
GSM_MESSAGE_MODE_DISCARD_REJECT = 1,
GSM_MESSAGE_MODE_BUFFER_FLUSH = 2,
GSM_MESSAGE_MODE_FORWARD = 3
} GSMMessageMode;
typedef enum _GSMMode
{
GSM_MODE_INIT = 0, GSM_MODE_COMMAND, GSM_MODE_PDU
} GSMMode;
typedef enum _GSMPhoneActivity
{
GSM_PHONE_ACTIVITY_READY = 0,
GSM_PHONE_ACTIVITY_UNKNOWN = 2,
GSM_PHONE_ACTIVITY_RINGING = 3,
GSM_PHONE_ACTIVITY_CALL = 4
} GSMPhoneActivity;
typedef enum _GSMPriority
{
GSM_PRIORITY_LOW = 0, GSM_PRIORITY_NORMAL, GSM_PRIORITY_HIGH,
GSM_PRIORITY_HIGHEST
} GSMPriority;
typedef enum _GSMRegistrationReport
{
GSM_REGISTRATION_REPORT_DISABLE = 0,
GSM_REGISTRATION_REPORT_ENABLE = 1,
GSM_REGISTRATION_REPORT_ENABLE_WITH_LOCATION = 2
} GSMRegistrationReport;
typedef enum _GSMRegistrationStatus
{
GSM_REGISTRATION_STATUS_NOT_SEARCHING = 0,
GSM_REGISTRATION_STATUS_REGISTERED_HOME = 1,
GSM_REGISTRATION_STATUS_NOT_REGISTERED = 2,
GSM_REGISTRATION_STATUS_DENIED = 3,
GSM_REGISTRATION_STATUS_UNKNOWN = 4,
GSM_REGISTRATION_STATUS_REGISTERED_ROAMING = 5
} GSMRegistrationStatus;
typedef enum _GSMStatus
{
GSM_STATUS_UNKNOWN = 0,
GSM_STATUS_INITIALIZED,
GSM_STATUS_READY,
GSM_STATUS_REGISTERING,
GSM_STATUS_REGISTERING_DENIED,
GSM_STATUS_REGISTERED_HOME,
GSM_STATUS_REGISTERED_ROAMING
} GSMStatus;
/* functions */
GSM * gsm_new(Config * config, char const * plugin, unsigned int retry);
void gsm_delete(GSM * gsm);
/* accessors */
ModemConfig * gsm_get_config(GSM * gsm);
unsigned int gsm_get_retry(GSM * gsm);
void gsm_set_callback(GSM * gsm, ModemEventCallback callback, void * priv);
int gsm_set_call_presentation(GSM * gsm, int set);
int gsm_set_call_waiting_control(GSM * gsm, int unsollicited);
int gsm_set_extended_ring_reports(GSM * gsm, int extended);
int gsm_set_mute(GSM * gsm, int mute);
int gsm_set_retry(GSM * gsm, unsigned int retry);
/* useful */
/* call management */
int gsm_call_answer(GSM * gsm);
int gsm_call(GSM * gsm, GSMCallType calltype, char const * number);
int gsm_call_contact(GSM * gsm, GSMCallType calltype, unsigned int index);
int gsm_call_hangup(GSM * gsm);
int gsm_call_reject(GSM * gsm);
/* callbacks */
void gsm_callback_on_message_deleted(GSM * gsm);
/* contacts */
int gsm_contact_delete(GSM * gsm, unsigned int index);
int gsm_contact_edit(GSM * gsm, unsigned int index, char const * name,
char const * number);
int gsm_contact_new(GSM * gsm, char const * name, char const * number);
int gsm_enter_sim_pin(GSM * gsm, char const * code);
/* fetching data */
int gsm_fetch_contact_list(GSM * gsm);
int gsm_fetch_contacts(GSM * gsm, unsigned int start, unsigned int end);
int gsm_fetch_message_list(GSM * gsm, GSMMessageList list);
int gsm_fetch_message(GSM * gsm, unsigned int id);
int gsm_fetch_mute(GSM * gsm);
int gsm_fetch_registration(GSM * gsm);
/* messaging */
int gsm_message_delete(GSM * gsm, unsigned int id);
int gsm_message_send(GSM * gsm, char const * number, GSMEncoding encoding,
char const * text, size_t length);
/* queries */
int gsm_is_alive(GSM * gsm);
int gsm_is_mute(GSM * gsm);
int gsm_is_phone_active(GSM * gsm);
int gsm_is_pin_valid(GSM * gsm);
int gsm_is_registered(GSM * gsm);
/* queue management */
GSMCommand * gsm_queue(GSM * gsm, char const * command);
int gsm_queue_command(GSM * gsm, GSMCommand * command);
int gsm_queue_full(GSM * gsm, GSMPriority priority, char const * command,
GSMError error, GSMCommandCallback callback);
int gsm_queue_full_mode(GSM * gsm, GSMPriority priority, char const * command,
GSMError error, GSMCommandCallback callback, GSMMode mode);
int gsm_queue_with_error(GSM * gsm, char const * command, GSMError error);
int gsm_start(GSM * gsm, unsigned int delay);
int gsm_stop(GSM * gsm);
int gsm_trigger(GSM * gsm, ModemEventType event);
#endif /* !PHONE_GSM_H */