calllist.h 5.37 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.beaudoin@savoirfairelinux.com>
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
4
5
6
 *                                                                              
 *  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
7
 *  the Free Software Foundation; either version 3 of the License, or
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
 *  (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>
24

Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
25
26
27
28
29
30
31
/** @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
32
typedef enum
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
33
34
35
36
37
38
39
40
41
42
43
{  /** 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
44
45
46
47
   CALL_STATE_HOLD,      
   /** Call has failed */
   CALL_STATE_FAILURE,      
   /** Call is busy */
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
48
49
   CALL_STATE_BUSY,        
   /** Call is being transfert.  During this state, the user can enter the new number. */
50
51
52
   CALL_STATE_TRANSFERT,
   /** Call is on hold */
   CALL_STATE_RECORD       
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
53
54
} call_state_t;

55
56
57
58
59
60
61
62
63
64
65
/**
 * @enum history_state
 * This enum have all the state a call can take in the history
 */
typedef enum
{
  NONE,
  INCOMING,
  OUTGOING,
  MISSED
} history_state_t;
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
66
67
68
69
70

/** @struct call_t
  * @brief Call information.
  * This struct holds information about a call.    
  */
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
71
typedef struct  {
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
72
  /** Unique identifier of the call */
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
73
  gchar * callID;
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
74
  /** The account used to place/receive the call */
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
75
  gchar * accountID;
76
/** The information about the calling person.  See call_get_name() and call_get_number()
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
77
    * on how to get the name and number separately. */
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
78
  gchar * from;
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
79
  /** The number we are calling.  Only used when dialing out */
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
80
  gchar * to;
81
  /** The current state of the call */
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
82
  call_state_t state;
83
84
  /** The history state */
  history_state_t history_state;
Emmanuel Milou's avatar
Emmanuel Milou committed
85
86
87
88

  time_t _start;
  time_t _stop;

Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
89
90
} call_t;

91
92
93
94
95
96
97
98
99
100
typedef struct {
	GtkListStore* store;
	GtkWidget* view;
	GtkWidget* tree;

	// Calllist vars
	GQueue* callQueue;
	call_t* selectedCall;
} calltab_t;

areversat's avatar
areversat committed
101
102
103
calltab_t* current_calls;
calltab_t* history;

104
105
/** This function initialize a call list. */
void call_list_init (calltab_t* tab);
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
106

Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
107
/** This function empty and free the call list. */
Emmanuel Milou's avatar
Emmanuel Milou committed
108
109
110
111
void call_list_clean(calltab_t* tab);

/** This function empty, free the call list and allocate a new one. */
void call_list_reset (calltab_t* tab);
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
112

113
114
115
116
117
118
/** Get the maximun number of calls in the history calltab */
gdouble call_history_get_max_calls( void ); 

/** Set the maximun number of calls in the history calltab */
void call_history_set_max_calls( const gdouble number ); 

Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
119
/** This function append a call to list. 
120
121
  * @param c The call you want to add 
  * */
122
void call_list_add (calltab_t* tab, call_t * c);
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
123

Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
124
125
126
/** This function remove a call from list. 
  * @param callID The callID of the call you want to remove
  */
127
void call_list_remove (calltab_t* tab, const gchar * callID);
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
128

Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
129
130
131
132
/** 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 */
133
call_t * call_list_get_by_state (calltab_t* tab, call_state_t state);
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
134

Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
135
136
/** Return the number of calls in the list
  * @return The number of calls in the list */
137
guint call_list_get_size (calltab_t* tab);
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
138

Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
139
140
141
/** Return the call at the nth position in the list
  * @param n The position of the call you want
  * @return A call or NULL */
142
call_t * call_list_get_nth (calltab_t* tab, guint n );
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
143
144
145
146

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

Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
149
150
151
/** 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 */
152
gchar * call_get_name ( const call_t * c);
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
153

154
155
156
157
158
/** 
 * 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
159
160
gchar * call_get_number (const call_t * c);

161
162
163
/** 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 */
164
void call_select (calltab_t* tab, call_t * c );
165
166
167

/** Return the selected call.
  * @return The number of the caller */
168
call_t * call_get_selected (calltab_t* tab);
Emmanuel Milou's avatar
Emmanuel Milou committed
169

170
171
172
/**
 * Clean the history. Delete all calls
 */
Emmanuel Milou's avatar
Emmanuel Milou committed
173
void call_list_clean_history();
174
175
176
177
178
179
180

/**
 * Remove one specified call from the history list
 * @param c The call to remove
 */
void call_list_remove_from_history( call_t* c);

Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
181
#endif