calllist.h 4.15 KB
Newer Older
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
1
2
/*
 *  Copyright (C) 2007 Savoir-Faire Linux inc.
3
 *  Author: Pierre-Luc Beaudoin <pierre-luc@squidy.info>
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
 *                                                                              
 *  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; either version 2 of the License, or
 *  (at your option) any later version.
 *                                                                                
 *  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, write to the Free Software
 *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */
 
#ifndef __CALLLIST_H__
#define __CALLLIST_H__

#include <gtk/gtk.h>
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
24
25
26
27
28
29
30
/** @file calllist.h
  * @brief A list to hold calls.
  */
  
/** @enum call_state_t 
  * This enum have all the states a call can take.
  */
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
31
typedef enum
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
32
33
34
35
36
37
38
39
40
41
42
{  /** Invalid state */
   CALL_STATE_INVALID = 0, 
   /** Ringing incoming call */
   CALL_STATE_INCOMING, 
   /** Ringing outgoing call */
   CALL_STATE_RINGING,  
   /** Call to which the user can speak and hear */
   CALL_STATE_CURRENT,  
   /** Call which numbers are being added by the user */
   CALL_STATE_DIALING,  
   /** Call is on hold */
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
43
44
45
46
   CALL_STATE_HOLD,      
   /** Call has failed */
   CALL_STATE_FAILURE,      
   /** Call is busy */
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
47
48
49
   CALL_STATE_BUSY,        
   /** Call is being transfert.  During this state, the user can enter the new number. */
   CALL_STATE_TRANSFERT       
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
50
51
} call_state_t;

Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
52
53
54
55
56

/** @struct call_t
  * @brief Call information.
  * This struct holds information about a call.    
  */
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
57
typedef struct  {
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
58
  /** Unique identifier of the call */
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
59
  gchar * callID;
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
60
  /** The account used to place/receive the call */
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
61
  gchar * accountID;
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
62
63
  /** The information about the calling person.  See call_get_name() and call_get_number()
    * on how to get the name and number separately. */
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
64
  gchar * from;
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
65
  /** The number we are calling.  Only used when dialing out */
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
66
  gchar * to;
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
67
  /* The current state of the call */
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
68
69
70
  call_state_t state;
} call_t;

Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
71
/** This function initialize the call list. */
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
72
73
void call_list_init ();

Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
74
/** This function empty and free the call list. */
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
75
76
void call_list_clean ();

Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
77
78
/** This function append a call to list. 
  * @param c The call you want to add */
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
79
80
void call_list_add (call_t * c);

Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
81
82
83
/** This function remove a call from list. 
  * @param callID The callID of the call you want to remove
  */
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
84
85
void call_list_remove (const gchar * callID);

Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
86
87
88
89
/** Return the first call that corresponds to the state.  
  * This is usefull for unique states as DIALING and CURRENT.
  * @param state The state
  * @return A call or NULL */
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
90
91
call_t * call_list_get_by_state ( call_state_t state);

Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
92
93
/** Return the number of calls in the list
  * @return The number of calls in the list */
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
94
95
guint call_list_get_size ( );

Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
96
97
98
/** Return the call at the nth position in the list
  * @param n The position of the call you want
  * @return A call or NULL */
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
99
call_t * call_list_get_nth ( guint n );
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
100
101
102
103

/** Return the call corresponding to the callID
  * @param n The callID of the call you want
  * @return A call or NULL */
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
104
105
call_t * call_list_get ( const gchar * callID );

Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
106
107
108
/** This function parse the call_t.from field to return the name
  * @param c The call
  * @return The full name of the caller or an empty string */
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
109
110
gchar * call_get_name (const call_t * c);

Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
111
112
113
/** This function parse the call_t.from field to return the number
  * @param c The call
  * @return The number of the caller */
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
114
115
gchar * call_get_number (const call_t * c);

116
117
118
119
120
121
122
123
/** Mark a call as selected.  There can be only one selected call.  This call
  * is the currently highlighted one in the list.
  * @param c The call */
void call_select ( call_t * c );

/** Return the selected call.
  * @return The number of the caller */
call_t * call_get_selected ();
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
124
#endif