1
/***************************************************************************
2
* Copyright (C) 2009-2012 by Savoir-Faire Linux *
3
* Author : Jérémy Quentin <jeremy.quentin@savoirfairelinux.com> *
4
* Emmanuel Lepage Valle <emmanuel.lepage@savoirfairelinux.com >*
6
* This program is free software; you can redistribute it and/or modify *
7
* it under the terms of the GNU General Public License as published by *
8
* the Free Software Foundation; either version 3 of the License, or *
9
* (at your option) any later version. *
11
* This program is distributed in the hope that it will be useful, *
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14
* GNU General Public License for more details. *
16
* You should have received a copy of the GNU General Public License *
17
* along with this program; if not, write to the *
18
* Free Software Foundation, Inc., *
19
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
20
**************************************************************************/
32
#include "sflphone_const.h"
38
/** @enum daemon_call_state_t
39
* This enum have all the states a call can take for the daemon.
43
/** Ringing outgoing or incoming call */
44
DAEMON_CALL_STATE_RINGING,
45
/** Call to which the user can speak and hear */
46
DAEMON_CALL_STATE_CURRENT,
48
DAEMON_CALL_STATE_BUSY,
49
/** Call is on hold */
50
DAEMON_CALL_STATE_HOLD,
52
DAEMON_CALL_STATE_HUNG_UP,
53
/** Call has failed */
54
DAEMON_CALL_STATE_FAILURE
58
* This enum have all the actions you can make on a call.
62
/** Green button, accept or new call or place call or place transfer */
64
/** Red button, refuse or hang up */
66
/** Blue button, put into or out of transfer mode where you can type transfer number */
68
/** Blue-green button, hold or unhold the call */
70
/** Record button, enable or disable recording */
76
* This enum have all the state a call can take in the history
89
typedef void (Call::*function)();
93
* This class represents a call either actual (in the call list
94
* displayed in main window), either past (in the call history).
95
* A call is represented by an automate, with a list of states
96
* (enum call_state) and 2 lists of transition signals
97
* (call_action when the user performs an action on the UI and
98
* daemon_call_state when the daemon sends a stateChanged signal)
99
* When a transition signal is received, the automate calls a
100
* function then go to a new state according to the previous state
101
* of the call and the signal received.
102
* The functions to call and the new states to go to are placed in
103
* the maps actionPerformedStateMap, actionPerformedFunctionMap,
104
* stateChangedStateMap and stateChangedFunctionMap.
105
* Those maps are used by actionPerformed and stateChanged functions
106
* to handle the behavior of the automate.
107
* When an actual call goes to the state OVER, it becomes part of
110
* It may be better to handle call list and call history separately,
111
* and to use the class Item to handle their display, or a model/view
112
* way. For this it needs to handle the becoming of a call to a past call
113
* keeping the information gathered by the call and needed by the history
114
* call (history state, start time...).
116
class LIB_EXPORT Call : public QObject
120
//Constructors & Destructors
121
Call(QString confId, QString account);
123
static Call* buildDialingCall (QString callId, const QString & peerName, QString account = "" );
124
static Call* buildIncomingCall (const QString & callId );
125
static Call* buildRingingCall (const QString & callId );
126
static Call* buildHistoryCall (const QString & callId, uint startTimeStamp, uint stopTimeStamp, QString account, QString name, QString number, QString type );
127
static Call* buildExistingCall (QString callId );
128
static void setContactBackend (ContactBackend* be );
131
static history_state getHistoryStateFromType ( QString type );
132
static QString getTypeFromHistoryState ( history_state historyState );
133
static call_state getStartStateFromDaemonCallState ( QString daemonCallState, QString daemonCallType );
134
static history_state getHistoryStateFromDaemonCallState ( QString daemonCallState, QString daemonCallType );
137
call_state getState () const;
138
const QString& getCallId () const;
139
const QString& getPeerPhoneNumber () const;
140
const QString& getPeerName () const;
141
call_state getCurrentState () const;
142
history_state getHistoryState () const;
143
bool getRecording () const;
144
const QString& getAccountId () const;
145
bool isHistory () const;
146
QString getStopTimeStamp () const;
147
QString getStartTimeStamp () const;
148
QString getCurrentCodecName () const;
149
bool isSecure () const;
150
bool isConference () const;
151
const QString& getConfId () const;
152
const QString& getTransferNumber () const;
153
const QString& getCallNumber () const;
156
call_state stateChanged(const QString & newState);
157
call_state actionPerformed(call_action action);
160
void setConference(bool value);
161
void setConfId(QString value);
162
void setTransferNumber(const QString& number);
163
void setCallNumber(const QString& number);
166
void appendText(const QString& str);
167
void backspaceItemText();
168
void changeCurrentState(call_state newState);
176
QString m_PeerPhoneNumber;
178
history_state m_HistoryState ;
179
QDateTime* m_pStartTime ;
180
QDateTime* m_pStopTime ;
181
QString m_TransferNumber ;
182
QString m_CallNumber ;
183
static ContactBackend* m_pContactBackend;
184
bool m_isConference ;
185
call_state m_CurrentState ;
188
//Automate attributes
190
* actionPerformedStateMap[orig_state][action]
191
* Map of the states to go to when the action action is
192
* performed on a call in state orig_state.
194
static const call_state actionPerformedStateMap [11][5];
197
* actionPerformedFunctionMap[orig_state][action]
198
* Map of the functions to call when the action action is
199
* performed on a call in state orig_state.
201
static const function actionPerformedFunctionMap [11][5];
204
* stateChangedStateMap[orig_state][daemon_new_state]
205
* Map of the states to go to when the daemon sends the signal
206
* callStateChanged with arg daemon_new_state
207
* on a call in state orig_state.
209
static const call_state stateChangedStateMap [11][6];
212
* stateChangedFunctionMap[orig_state][daemon_new_state]
213
* Map of the functions to call when the daemon sends the signal
214
* callStateChanged with arg daemon_new_state
215
* on a call in state orig_state.
217
static const function stateChangedFunctionMap [11][6];
219
static const char * historyIcons[3];
221
static const char * callStateIcons[11];
223
Call(call_state startState, QString callId, QString peerNumber = "", QString account = "", QString peerName = "");
225
static daemon_call_state toDaemonCallState(const QString & stateName);
228
// See actionPerformedFunctionMap and stateChangedFunctionMap
229
// to know when it is called.
233
void acceptTransf ();
241
void switchRecord ();