Closed ticket #1107: iOS4 background feature

 * pjlib:
  * add support for activesock TCP to work in background mode.
  * add feature in ioqueue to recreate closed UDP sockets.
 * pjsip-apps:
  * ipjsua: add support for iPhone OS 4 background mode
  * ipjsystest: add support for iPhone OS 4 background mode



git-svn-id: https://svn.pjsip.org/repos/pjproject/trunk@3299 74dad513-b988-da41-8d7b-12977e46ad98
diff --git a/pjlib/include/pj/activesock.h b/pjlib/include/pj/activesock.h
index c7fc908..1ebb5a2 100644
--- a/pjlib/include/pj/activesock.h
+++ b/pjlib/include/pj/activesock.h
@@ -302,6 +302,21 @@
  */
 PJ_DECL(pj_status_t) pj_activesock_close(pj_activesock_t *asock);
 
+#if defined(PJ_IPHONE_OS_HAS_MULTITASKING_SUPPORT) && \
+    PJ_IPHONE_OS_HAS_MULTITASKING_SUPPORT!=0
+/**
+ * Set iPhone OS background mode setting. Setting to 1 will enable TCP
+ * active socket to receive incoming data when application is in the
+ * background. Setting to 0 will disable it. Default value of this
+ * setting is PJ_ACTIVESOCK_TCP_IPHONE_OS_BG.
+ *
+ * @param asock	    The active socket.
+ * @param val	    The value of background mode setting.
+ *
+ */
+PJ_DECL(void) pj_activesock_set_iphone_os_bg(pj_activesock_t *asock,
+					     int val);
+#endif
 
 /**
  * Associate arbitrary data with the active socket. Application may
diff --git a/pjlib/include/pj/compat/os_auto.h.in b/pjlib/include/pj/compat/os_auto.h.in
index 6fe3276..5c5f74b 100644
--- a/pjlib/include/pj/compat/os_auto.h.in
+++ b/pjlib/include/pj/compat/os_auto.h.in
@@ -169,13 +169,17 @@
 /* The type of atomic variable value: */
 #undef PJ_ATOMIC_VALUE_TYPE
 
-/* Append ".local" suffix to the system's hostname? */
 #if defined(PJ_DARWINOS) && PJ_DARWINOS!=0
 #    include "TargetConditionals.h"
 #    if TARGET_OS_IPHONE
 #	include "Availability.h"
 #    	ifdef __IPHONE_4_0
-#	    define PJ_GETHOSTNAME_APPEND_LOCAL_SUFFIX 1
+ 	    /* Append ".local" suffix to the system's hostname? (see ticket #1104) */
+#	    define PJ_GETHOSTNAME_APPEND_LOCAL_SUFFIX 		1
+ 	    /* Is multitasking support available?  (see ticket #1107) */
+#	    define PJ_IPHONE_OS_HAS_MULTITASKING_SUPPORT 	1
+	    /* Enable activesock TCP background mode support */
+#	    define PJ_ACTIVESOCK_TCP_IPHONE_OS_BG		1
 #	endif
 #    endif
 #endif