calllist.h 5.68 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>
4
 *
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
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
 *  (at your option) any later version.
9
 *
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
10 11 12 13
 *  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.
14
 *
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
15 16 17 18
 *  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.
 */
19

Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
20 21 22 23
#ifndef __CALLLIST_H__
#define __CALLLIST_H__

#include <gtk/gtk.h>
24

Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
25 26 27
/** @file calllist.h
  * @brief A list to hold calls.
  */
28 29

/** @enum call_state_t
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
30 31
  * 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
{  /** Invalid state */
34
   CALL_STATE_INVALID = 0,
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
35
   /** Ringing incoming call */
36
   CALL_STATE_INCOMING,
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
37
   /** Ringing outgoing call */
38
   CALL_STATE_RINGING,
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
39
   /** Call to which the user can speak and hear */
40
   CALL_STATE_CURRENT,
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
41
   /** Call which numbers are being added by the user */
42
   CALL_STATE_DIALING,
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
43
   /** Call is on hold */
44
   CALL_STATE_HOLD,
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
45
   /** Call has failed */
46
   CALL_STATE_FAILURE,
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
47
   /** Call is busy */
48
   CALL_STATE_BUSY,
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
49
   /** Call is being transfert.  During this state, the user can enter the new number. */
50 51
   CALL_STATE_TRANSFERT,
   /** Call is on hold */
52
   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 71 72 73 74 75 76 77
/**
 * @enum call_type
 * This enum have all types of call
 */
typedef enum
{
  CALL,
  HISTORY,
  CONTACT
} call_type_t;

78 79 80 81 82 83
/**
 * @enum contact_type
 * This enum have all types of contacts: HOME phone, cell phone, etc...
 */
typedef enum
{
Emmanuel Milou's avatar
Emmanuel Milou committed
84 85 86
  CONTACT_PHONE_HOME,
  CONTACT_PHONE_BUSINESS,
  CONTACT_PHONE_MOBILE
87 88
} contact_type_t;

Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
89 90
/** @struct call_t
  * @brief Call information.
91
  * This struct holds information about a call.
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
92
  */
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
93
typedef struct  {
94 95
  /** Type of call entry */
  call_type_t call_type;
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
96
  /** Unique identifier of the call */
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
97
  gchar * callID;
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
98
  /** The account used to place/receive the call */
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
99
  gchar * accountID;
100
  /** The information about the calling person.  See call_get_name() and call_get_number()
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
101
    * on how to get the name and number separately. */
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
102
  gchar * from;
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
103
  /** The number we are calling.  Only used when dialing out */
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
104
  gchar * to;
105
  /** The current state of the call */
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
106
  call_state_t state;
107
  /** The history state if necessary */
108
  history_state_t history_state;
109 110

  GdkPixbuf *contact_thumbnail;
Emmanuel Milou's avatar
Emmanuel Milou committed
111 112 113 114

  time_t _start;
  time_t _stop;

Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
115 116
} call_t;

117 118 119 120 121 122 123 124 125 126
typedef struct {
	GtkListStore* store;
	GtkWidget* view;
	GtkWidget* tree;

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

areversat's avatar
areversat committed
127 128
calltab_t* current_calls;
calltab_t* history;
129
calltab_t* contacts;
areversat's avatar
areversat committed
130

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

Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
134
/** This function empty and free the call list. */
Emmanuel Milou's avatar
Emmanuel Milou committed
135 136 137 138
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
139

140
/** Get the maximun number of calls in the history calltab */
141
gdouble call_history_get_max_calls( void );
142 143

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

146 147
/** This function append a call to list.
  * @param c The call you want to add
148
  * */
149
void call_list_add (calltab_t* tab, call_t * c);
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
150

151
/** This function remove a call from list.
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
152 153
  * @param callID The callID of the call you want to remove
  */
154
void call_list_remove (calltab_t* tab, const gchar * callID);
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
155

156
/** Return the first call that corresponds to the state.
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
157 158 159
  * This is usefull for unique states as DIALING and CURRENT.
  * @param state The state
  * @return A call or NULL */
160
call_t * call_list_get_by_state (calltab_t* tab, call_state_t state);
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
161

Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
162 163
/** Return the number of calls in the list
  * @return The number of calls in the list */
164
guint call_list_get_size (calltab_t* tab);
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
165

Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
166 167 168
/** Return the call at the nth position in the list
  * @param n The position of the call you want
  * @return A call or NULL */
169
call_t * call_list_get_nth (calltab_t* tab, guint n );
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
170 171 172 173

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

Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
176 177 178
/** 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 */
179
gchar * call_get_name ( const call_t * c);
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
180

181
/**
182 183
 * This function parse the call_t.from field to return the number
 * @param c The call
184
 * @return The number of the caller
185
 */
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
186 187
gchar * call_get_number (const call_t * c);

188 189 190
/** 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 */
191
void call_select (calltab_t* tab, call_t * c );
192 193 194

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

197 198 199
/**
 * Clean the history. Delete all calls
 */
Emmanuel Milou's avatar
Emmanuel Milou committed
200
void call_list_clean_history();
201 202 203 204 205 206 207

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

Emmanuel Milou's avatar
Emmanuel Milou committed
208
void create_new_call (gchar *to, gchar *from, call_state_t state, gchar *accountID, call_t **new_call);
209 210 211

void attach_thumbnail (call_t *call, GdkPixbuf *pixbuf);

212
#endif