~noskcaj/ubuntu/saucy/sflphone/merge-1.2.3-2

« back to all changes in this revision

Viewing changes to kde/src/lib/Call.h

  • Committer: Package Import Robot
  • Author(s): Francois Marier
  • Date: 2012-02-18 21:47:09 UTC
  • mfrom: (1.1.6)
  • Revision ID: package-import@ubuntu.com-20120218214709-6362d71gqdsdkrj5
Tags: 1.0.2-1
* New upstream release
  - remove logging patch (applied upstream)
  - update s390 patch since it was partially applied upstream
* Include the Evolution plugin as a separate binary package

* Fix compilation issues on SH4 (closes: #658987)
* Merge Ubuntu's binutils-gold linking fix

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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 >*
 
5
 *                                                                         *
 
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.                                   *
 
10
 *                                                                         *
 
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.                          *
 
15
 *                                                                         *
 
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
 **************************************************************************/
 
21
 
 
22
 
 
23
#ifndef CALL_H
 
24
#define CALL_H
 
25
 
 
26
//Qt
 
27
class QString;
 
28
class QDateTime;
 
29
class QLabel;
 
30
class QWidget;
 
31
 
 
32
#include "sflphone_const.h"
 
33
#include "typedefs.h"
 
34
 
 
35
class ContactBackend;
 
36
 
 
37
 
 
38
/** @enum daemon_call_state_t 
 
39
  * This enum have all the states a call can take for the daemon.
 
40
  */
 
41
typedef enum
 
42
 
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,
 
47
   /** Call is busy */
 
48
   DAEMON_CALL_STATE_BUSY,
 
49
   /** Call is on hold */
 
50
   DAEMON_CALL_STATE_HOLD,
 
51
   /** Call is over  */
 
52
   DAEMON_CALL_STATE_HUNG_UP,
 
53
   /** Call has failed */
 
54
   DAEMON_CALL_STATE_FAILURE
 
55
} daemon_call_state;
 
56
 
 
57
/** @enum call_action
 
58
  * This enum have all the actions you can make on a call.
 
59
  */
 
60
typedef enum
 
61
 
62
   /** Green button, accept or new call or place call or place transfer */
 
63
   CALL_ACTION_ACCEPT,
 
64
   /** Red button, refuse or hang up */
 
65
   CALL_ACTION_REFUSE,
 
66
   /** Blue button, put into or out of transfer mode where you can type transfer number */
 
67
   CALL_ACTION_TRANSFER,
 
68
   /** Blue-green button, hold or unhold the call */
 
69
   CALL_ACTION_HOLD,
 
70
   /** Record button, enable or disable recording */
 
71
   CALL_ACTION_RECORD,
 
72
} call_action;
 
73
 
 
74
/**
 
75
 * @enum history_state
 
76
 * This enum have all the state a call can take in the history
 
77
 */
 
78
typedef enum
 
79
{
 
80
  INCOMING,
 
81
  OUTGOING,
 
82
  MISSED,
 
83
  NONE
 
84
} history_state;
 
85
 
 
86
 
 
87
class Call;
 
88
 
 
89
typedef  void (Call::*function)();
 
90
 
 
91
 
 
92
/**
 
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
 
108
 *  the call history.
 
109
 *
 
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...).
 
115
**/
 
116
class  LIB_EXPORT Call : public QObject
 
117
{
 
118
   Q_OBJECT
 
119
public:
 
120
   //Constructors & Destructors
 
121
   Call(QString confId, QString account);
 
122
   ~Call();
 
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                                                                                                           );
 
129
 
 
130
   //Static getters
 
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 );
 
135
   
 
136
   //Getters
 
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;
 
154
 
 
155
   //Automated function
 
156
   call_state stateChanged(const QString & newState);
 
157
   call_state actionPerformed(call_action action);
 
158
   
 
159
   //Setters
 
160
   void setConference(bool value);
 
161
   void setConfId(QString value);
 
162
   void setTransferNumber(const QString& number);
 
163
   void setCallNumber(const QString& number);
 
164
   
 
165
   //Mutators
 
166
   void appendText(const QString& str);
 
167
   void backspaceItemText();
 
168
   void changeCurrentState(call_state newState);
 
169
   
 
170
private:
 
171
 
 
172
   //Attributes
 
173
   QString                m_Account        ;
 
174
   QString                m_CallId         ;
 
175
   QString                m_ConfId         ;
 
176
   QString                m_PeerPhoneNumber;
 
177
   QString                m_PeerName       ;
 
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   ;
 
186
   bool                   m_Recording      ;
 
187
   
 
188
   //Automate attributes
 
189
   /**
 
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.
 
193
   **/
 
194
   static const call_state actionPerformedStateMap [11][5];
 
195
   
 
196
   /**
 
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.
 
200
   **/
 
201
   static const function actionPerformedFunctionMap [11][5];
 
202
   
 
203
   /**
 
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.
 
208
   **/
 
209
   static const call_state stateChangedStateMap [11][6];
 
210
   
 
211
   /**
 
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.
 
216
   **/
 
217
   static const function stateChangedFunctionMap [11][6];
 
218
   
 
219
   static const char * historyIcons[3];
 
220
   
 
221
   static const char * callStateIcons[11];
 
222
 
 
223
   Call(call_state startState, QString callId, QString peerNumber = "", QString account = "", QString peerName = "");
 
224
   
 
225
   static daemon_call_state toDaemonCallState(const QString & stateName);
 
226
   
 
227
   //Automate functions
 
228
   // See actionPerformedFunctionMap and stateChangedFunctionMap
 
229
   // to know when it is called.
 
230
   void nothing      ();
 
231
   void accept       ();
 
232
   void refuse       ();
 
233
   void acceptTransf ();
 
234
   void acceptHold   ();
 
235
   void hangUp       ();
 
236
   void cancel       ();
 
237
   void hold         ();
 
238
   void call         ();
 
239
   void transfer     ();
 
240
   void unhold       ();
 
241
   void switchRecord ();
 
242
   void setRecord    ();
 
243
   void start        ();
 
244
   void startStop    ();
 
245
   void stop         ();
 
246
   void startWeird   ();
 
247
   void warning      ();
 
248
 
 
249
signals:
 
250
   void changed();
 
251
   void isOver(Call*);
 
252
};
 
253
 
 
254
#endif