call.h 3.18 KB
Newer Older
yanmorin's avatar
 
yanmorin committed
1 2
/*
 *  Copyright (C) 2004-2006 Savoir-Faire Linux inc.
jpbl's avatar
jpbl committed
3
 *  Author: Yan Morin <yan.morin@savoirfairelinux.com>
yanmorin's avatar
 
yanmorin committed
4 5
 *  Author : Laurielle Lea <laurielle.lea@savoirfairelinux.com>
 *
jpbl's avatar
jpbl committed
6 7 8 9
 *  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.
yanmorin's avatar
 
yanmorin committed
10
 *
jpbl's avatar
jpbl committed
11 12 13 14
 *  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.
yanmorin's avatar
 
yanmorin committed
15
 *
jpbl's avatar
jpbl committed
16 17 18 19
 *  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.
 */
yanmorin's avatar
 
yanmorin committed
20 21
#ifndef CALL_H
#define CALL_H
jpbl's avatar
jpbl committed
22 23

#include <string>
yanmorin's avatar
 
yanmorin committed
24 25 26 27 28 29 30 31 32 33 34 35 36 37
#include <cc++/thread.h> // for mutex

//TODO: remove this, it's only for call ID
typedef std::string CallID;

/**
	@author Yan Morin <yan.morin@gmail.com>
  A call is the base classes for protocol-based calls
*/
class Call{
public:
    enum CallType {Incoming, Outgoing};
    enum ConnectionState {Disconnected, Trying, Progressing, Ringing, Connected };
    enum CallState {Inactive, Active, Hold, Busy, Refused, Error};
jpbl's avatar
jpbl committed
38

yanmorin's avatar
 
yanmorin committed
39 40 41 42 43 44 45
    /**
     * Constructor of a call
     * @param id Unique identifier of the call
     * @param type set definitely this call as incoming/outgoing
     */
    Call(const CallID& id, Call::CallType type);
    virtual ~Call();
jpbl's avatar
jpbl committed
46

yanmorin's avatar
 
yanmorin committed
47 48 49 50 51
    /** 
     * Return a reference on the call id
     * @return call id
     */
    CallID& getCallId() {return _id; }
jpbl's avatar
jpbl committed
52

yanmorin's avatar
 
yanmorin committed
53 54 55 56 57 58 59
    /** 
     * Set the peer number (destination on outgoing)
     * not protected by mutex (when created)
     * @param number peer number
     */
    void setPeerNumber(const std::string& number) {  _peerNumber = number; }
    const std::string& getPeerNumber() {  return _peerNumber; }
jpbl's avatar
jpbl committed
60

yanmorin's avatar
 
yanmorin committed
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
    /** 
     * Set the peer name (caller in ingoing)
     * not protected by mutex (when created)
     * @param number peer number
     */
    void setPeerName(const std::string& name) {  _peerName = name; }
    const std::string& getPeerName() {  return _peerName; }

    /** 
     * Set the connection state of the call (protected by mutex)
     */
    void setConnectionState(ConnectionState state);
    /** 
     * get the connection state of the call (protected by mutex)
     */
    ConnectionState getConnectionState();
yanmorin's avatar
 
yanmorin committed
77

yanmorin's avatar
 
yanmorin committed
78 79 80 81 82 83 84 85
    /**
     * Set the state of the call (protected by mutex)
     */
    void setState(CallState state);
    /** 
     * get the call state of the call (protected by mutex)
     */
    CallState getState();
jpbl's avatar
jpbl committed
86

yanmorin's avatar
 
yanmorin committed
87 88 89
protected:
    /** Protect every attribute that can be changed by two threads */
    ost::Mutex _callMutex;
jpbl's avatar
jpbl committed
90

yanmorin's avatar
 
yanmorin committed
91 92 93
private:  
    /** Unique ID of the call */
    CallID _id;
jpbl's avatar
jpbl committed
94

yanmorin's avatar
 
yanmorin committed
95 96 97 98 99 100
    /** Type of the call */
    CallType _type;
    /** Disconnected/Progressing/Trying/Ringing/Connected */
    ConnectionState _connectionState;
    /** Inactive/Active/Hold/Busy/Refused/Error */
    CallState _callState;
jpbl's avatar
jpbl committed
101

yanmorin's avatar
 
yanmorin committed
102 103
    /** Name of the peer */
    std::string _peerName;
jpbl's avatar
jpbl committed
104

yanmorin's avatar
 
yanmorin committed
105 106
    /** Number of the peer */
    std::string _peerNumber;
jpbl's avatar
jpbl committed
107 108
};

yanmorin's avatar
 
yanmorin committed
109
#endif