Desktop
/* $Id: modem.h,v 1.1.2.11 2011/01/22 03:08:54 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/>. */
/* TODO:
* - allow the plug-in to specify the configuration values expected */
#ifndef DESKTOP_PHONE_MODEM_H
# define DESKTOP_PHONE_MODEM_H
# include <sys/types.h>
/* Modem */
/* types */
typedef struct _Modem Modem;
typedef enum _ModemAuthenticationMethod
{
MODEM_AUTHENTICATION_METHOD_NONE = 0,
MODEM_AUTHENTICATION_METHOD_PIN
} ModemAuthenticationMethod;
typedef enum _ModemAuthenticationStatus
{
MODEM_AUTHENTICATION_STATUS_OK = 0,
MODEM_AUTHENTICATION_STATUS_REQUIRED,
MODEM_AUTHENTICATION_STATUS_ERROR
} ModemAuthenticationStatus;
typedef enum _ModemBatteryStatus
{
MODEM_BATTERY_STATUS_UNKNOWN = 0,
MODEM_BATTERY_STATUS_NONE,
MODEM_BATTERY_STATUS_CONNECTED,
MODEM_BATTERY_STATUS_CHARGING,
MODEM_BATTERY_STATUS_ERROR
} ModemBatteryStatus;
typedef enum _ModemCallDirection
{
MODEM_CALL_DIRECTION_NONE = 0,
MODEM_CALL_DIRECTION_INCOMING,
MODEM_CALL_DIRECTION_OUTGOING
} ModemCallDirection;
typedef enum _ModemCallStatus
{
MODEM_CALL_STATUS_NONE = 0,
MODEM_CALL_STATUS_RINGING,
MODEM_CALL_STATUS_ACTIVE
} ModemCallStatus;
typedef enum _ModemMessageEncoding
{
MODEM_MESSAGE_ENCODING_NONE = 0,
MODEM_MESSAGE_ENCODING_DATA,
MODEM_MESSAGE_ENCODING_ASCII,
MODEM_MESSAGE_ENCODING_UTF8
} ModemMessageEncoding;
typedef enum _ModemRegistrationMode
{
MODEM_REGISTRATION_MODE_UNKNOWN = 0,
MODEM_REGISTRATION_MODE_AUTOMATIC,
MODEM_REGISTRATION_MODE_MANUAL,
MODEM_REGISTRATION_MODE_DISABLED
} ModemRegistrationMode;
typedef enum _ModemRegistrationStatus
{
MODEM_REGISTRATION_STATUS_UNKNOWN = 0,
MODEM_REGISTRATION_STATUS_NOT_SEARCHING,
MODEM_REGISTRATION_STATUS_SEARCHING,
MODEM_REGISTRATION_STATUS_REGISTERED,
MODEM_REGISTRATION_STATUS_DENIED
} ModemRegistrationStatus;
typedef enum _ModemEventType
{
MODEM_EVENT_TYPE_ERROR = 0,
MODEM_EVENT_TYPE_AUTHENTICATION,
MODEM_EVENT_TYPE_BATTERY_LEVEL,
MODEM_EVENT_TYPE_CALL,
MODEM_EVENT_TYPE_CONTACT,
MODEM_EVENT_TYPE_MESSAGE,
MODEM_EVENT_TYPE_MESSAGE_SENT,
MODEM_EVENT_TYPE_MODEL,
MODEM_EVENT_TYPE_REGISTRATION
} ModemEventType;
# define MODEM_EVENT_TYPE_LAST MODEM_EVENT_TYPE_REGISTRATION
# define MODEM_EVENT_TYPE_COUNT (MODEM_EVENT_TYPE_LAST + 1)
typedef union _ModemEvent
{
ModemEventType type;
/* MODEM_EVENT_TYPE_ERROR */
struct
{
ModemEventType type;
char const * message;
} error;
/* MODEM_EVENT_TYPE_AUTHENTICATION */
struct
{
ModemEventType type;
char const * name;
ModemAuthenticationMethod method;
ModemAuthenticationStatus status;
int retries;
} authentication;
/* MODEM_EVENT_TYPE_BATTERY_LEVEL */
struct
{
ModemEventType type;
ModemBatteryStatus status;
double level;
} battery_level;
/* MODEM_EVENT_TYPE_CALL */
struct
{
ModemEventType type;
ModemCallDirection direction;
ModemCallStatus status;
char const * number;
} call;
/* MODEM_EVENT_TYPE_CONTACT */
struct
{
ModemEventType type;
unsigned int id;
char const * name;
char const * number;
} contact;
/* MODEM_EVENT_TYPE_MESSAGE */
struct
{
ModemEventType type;
unsigned int id;
time_t date;
char const * number;
ModemMessageEncoding encoding;
size_t length;
char const * content;
} message;
/* MODEM_EVENT_TYPE_MESSAGE_SENT */
struct
{
ModemEventType type;
unsigned int id;
} message_sent;
/* MODEM_EVENT_TYPE_MODEL */
struct
{
ModemEventType type;
char const * vendor;
char const * name;
char const * version;
} model;
/* MODEM_EVENT_TYPE_REGISTRATION */
struct
{
ModemEventType type;
ModemRegistrationMode mode;
ModemRegistrationStatus status;
char const * media;
char const * _operator;
double signal;
int roaming;
} registration;
} ModemEvent;
typedef enum _ModemRequestType
{
MODEM_REQUEST_AUTHENTICATE,
MODEM_REQUEST_CALL,
MODEM_REQUEST_CALL_ANSWER,
MODEM_REQUEST_CALL_CONTACT,
MODEM_REQUEST_CALL_HANGUP,
MODEM_REQUEST_CALL_LAST,
MODEM_REQUEST_CALL_MUTE_DISABLE,
MODEM_REQUEST_CALL_MUTE_ENABLE,
MODEM_REQUEST_CALL_PRESENTATION,
MODEM_REQUEST_CALL_WAITING_CONTROL,
MODEM_REQUEST_CONTACT,
MODEM_REQUEST_CONTACT_DELETE,
MODEM_REQUEST_CONTACT_EDIT,
MODEM_REQUEST_CONTACT_LIST,
MODEM_REQUEST_CONTACT_NEW,
MODEM_REQUEST_ENTER_SIM_PIN,
MODEM_REQUEST_GPRS_ATTACHED,
MODEM_REQUEST_LINE_PRESENTATION,
MODEM_REQUEST_MESSAGE,
MODEM_REQUEST_MESSAGE_DELETE,
MODEM_REQUEST_MESSAGE_LIST,
MODEM_REQUEST_MESSAGE_SEND,
MODEM_REQUEST_OPERATOR,
MODEM_REQUEST_OPERATOR_FORMAT,
MODEM_REQUEST_OPERATOR_MODE,
MODEM_REQUEST_REGISTRATION,
MODEM_REQUEST_REGISTRATION_REPORT,
MODEM_REQUEST_SIGNAL_LEVEL,
MODEM_REQUEST_SUPPLEMENTARY_SERVICE_NOTIFICATIONS
} ModemRequestType;
# define MODEM_REQUEST_LAST MODEM_REQUEST_SUPPLEMENTARY_SERVICE_NOTIFICATIONS
# define MODEM_REQUEST_COUNT (MODEM_REQUEST_LAST + 1)
typedef union _ModemRequest
{
ModemRequestType type;
/* MODEM_REQUEST_AUTHENTICATE */
struct
{
ModemRequestType type;
char const * username;
char const * password;
} authenticate;
/* MODEM_REQUEST_CALL */
struct
{
ModemRequestType type;
char const * number;
} call;
/* MODEM_REQUEST_CALL_PRESENTATION */
struct
{
ModemRequestType type;
int enabled;
} call_presentation;
/* MODEM_REQUEST_CONTACT */
struct
{
ModemRequestType type;
unsigned int id;
} contact;
/* MODEM_REQUEST_MESSAGE */
struct
{
ModemRequestType type;
unsigned int id;
} message;
} ModemRequest;
typedef struct _ModemPluginHelper
{
Modem * modem;
char const * (*config_get)(Modem * modem, char const * section,
char const * variable);
int (*error)(Modem * modem, char const * message, int ret);
void (*event)(Modem * modem, ModemEvent * event);
} ModemPluginHelper;
typedef struct _ModemPlugin ModemPlugin;
struct _ModemPlugin
{
ModemPluginHelper * helper;
char const * name;
char const * icon;
int (*init)(ModemPlugin * plugin);
int (*destroy)(ModemPlugin * plugin);
int (*start)(ModemPlugin * plugin);
int (*stop)(ModemPlugin * plugin);
int (*request)(ModemPlugin * plugin, ModemRequest * request);
int (*trigger)(ModemPlugin * plugin, ModemEventType event);
void * priv;
};
#endif /* !DESKTOP_PHONE_MODEM_H */