|
From: <do...@us...> - 2008-11-03 20:16:40
|
Revision: 1452
http://iaxclient.svn.sourceforge.net/iaxclient/?rev=1452&view=rev
Author: dohpaz
Date: 2008-11-03 20:16:06 +0000 (Mon, 03 Nov 2008)
Log Message:
-----------
Add better error / state checking to iaxc_answer_call() and add return value.
Modified Paths:
--------------
branches/team/elbunce/iaxclient/lib/iaxclient.h
branches/team/elbunce/iaxclient/lib/iaxclient_lib.c
Modified: branches/team/elbunce/iaxclient/lib/iaxclient.h
===================================================================
--- branches/team/elbunce/iaxclient/lib/iaxclient.h 2008-08-26 18:01:51 UTC (rev 1451)
+++ branches/team/elbunce/iaxclient/lib/iaxclient.h 2008-11-03 20:16:06 UTC (rev 1452)
@@ -812,8 +812,10 @@
/*!
Answers the incoming call \a callNo.
\param callNo The number of the call to answer.
+
+ \return 0 upon success; -1 otherwise
*/
-EXPORT void iaxc_answer_call(int callNo);
+EXPORT int iaxc_answer_call(int callNo);
/*!
Radio Transmitter and Receiver Control Activiate
@@ -880,7 +882,7 @@
EXPORT void iaxc_send_dtmf(char digit);
/*!
- Sends text to the currently selected call.
+ Sends \a text to the currently selected call.
*/
EXPORT void iaxc_send_text(const char * text);
Modified: branches/team/elbunce/iaxclient/lib/iaxclient_lib.c
===================================================================
--- branches/team/elbunce/iaxclient/lib/iaxclient_lib.c 2008-08-26 18:01:51 UTC (rev 1451)
+++ branches/team/elbunce/iaxclient/lib/iaxclient_lib.c 2008-11-03 20:16:06 UTC (rev 1452)
@@ -1488,15 +1488,30 @@
iax_busy(calls[callNo].session);
}
-EXPORT void iaxc_answer_call(int callNo)
+EXPORT int iaxc_answer_call(int callNo)
{
- if ( callNo < 0 )
- return;
+ /* default result of success */
+ int res = 0;
- calls[callNo].state |= IAXC_CALL_STATE_COMPLETE;
- calls[callNo].state &= ~IAXC_CALL_STATE_RINGING;
- iax_answer(calls[callNo].session);
- iaxci_do_state_callback(callNo);
+ /* Make sure call is valid, within range */
+ if ( ( callNo < 0 ) || ( callNo >= max_calls ) )
+ return -1;
+
+ get_iaxc_lock();
+ /* make sure this isn't free and not-outgoing */
+ if ( ( calls[callNo].state != IAXC_CALL_STATE_FREE ) &&
+ ! ( calls[callNo].state & IAXC_CALL_STATE_OUTGOING ) )
+ {
+ calls[callNo].state |= IAXC_CALL_STATE_COMPLETE;
+ calls[callNo].state &= ~IAXC_CALL_STATE_RINGING;
+ iax_answer(calls[callNo].session);
+ iaxci_do_state_callback(callNo);
+ }
+ else
+ res = -1;
+
+ put_iaxc_lock();
+ return res;
}
EXPORT void iaxc_key_radio(int callNo)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|