summaryrefslogtreecommitdiff
path: root/pjlib
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2007-10-26 05:25:35 +0000
committerBenny Prijono <bennylp@teluu.com>2007-10-26 05:25:35 +0000
commitdbeb703e133db47a744bec62a7c990f7ef0750d5 (patch)
tree35f5c062a4fdcfb2f52ef7028dd1cef803606375 /pjlib
parent5ed4dadd94be8e20c9b33f89772c135d992473d2 (diff)
Ticket #403: Ability to specify RConnection instance etc in PJLIB Symbian
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@1525 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjlib')
-rw-r--r--pjlib/include/pj/os.h42
-rw-r--r--pjlib/src/pj/os_core_symbian.cpp34
-rw-r--r--pjlib/src/pj/os_symbian.h21
-rw-r--r--pjlib/src/pj/sock_symbian.cpp9
4 files changed, 99 insertions, 7 deletions
diff --git a/pjlib/include/pj/os.h b/pjlib/include/pj/os.h
index 10cc5520..3529c463 100644
--- a/pjlib/include/pj/os.h
+++ b/pjlib/include/pj/os.h
@@ -293,6 +293,48 @@ PJ_DECL(pj_status_t) pj_thread_get_stack_info(pj_thread_t *thread,
*/
PJ_DECL(pj_bool_t) pj_symbianos_poll(int priority, int ms_timeout);
+
+/**
+ * This structure declares Symbian OS specific parameters that can be
+ * specified when calling #pj_symbianos_set_params().
+ */
+typedef struct pj_symbianos_params
+{
+ /**
+ * Optional RSocketServ instance to be used by PJLIB. If this
+ * value is NULL, PJLIB will create a new RSocketServ instance
+ * when pj_init() is called.
+ */
+ void *rsocketserv;
+
+ /**
+ * Optional RConnection instance to be used by PJLIB when creating
+ * sockets. If this value is NULL, no RConnection will be
+ * specified when creating sockets.
+ */
+ void *rconnection;
+
+ /**
+ * Optional RHostResolver instance to be used by PJLIB. If this value
+ * is NULL, a new RHostResolver instance will be created when
+ * pj_init() is called.
+ */
+ void *rhostresolver;
+
+} pj_symbianos_params;
+
+/**
+ * Specify Symbian OS parameters to be used by PJLIB. This function MUST
+ * be called before #pj_init() is called.
+ *
+ * @param prm Symbian specific parameters.
+ *
+ * @return PJ_SUCCESS if the parameters can be applied
+ * successfully.
+ */
+PJ_DECL(pj_status_t) pj_symbianos_set_params(pj_symbianos_params *prm);
+
+
/**
* @}
*/
diff --git a/pjlib/src/pj/os_core_symbian.cpp b/pjlib/src/pj/os_core_symbian.cpp
index f13365a5..8f96ce09 100644
--- a/pjlib/src/pj/os_core_symbian.cpp
+++ b/pjlib/src/pj/os_core_symbian.cpp
@@ -153,10 +153,19 @@ TInt CPjTimeoutTimer::RunError(TInt aError)
PjSymbianOS::PjSymbianOS()
: isSocketServInitialized_(false), isResolverInitialized_(false),
- console_(NULL), selectTimeoutTimer_(NULL)
+ console_(NULL), selectTimeoutTimer_(NULL),
+ appSocketServ_(NULL), appConnection_(NULL), appHostResolver_(NULL)
{
}
+// Set parameters
+void PjSymbianOS::SetParameters(pj_symbianos_params *params)
+{
+ appSocketServ_ = (RSocketServ*) params->rsocketserv;
+ appConnection_ = (RConnection*) params->rconnection;
+ appHostResolver_ = (RHostResolver*) params->rhostresolver;
+}
+
// Get PjSymbianOS instance
PjSymbianOS *PjSymbianOS::Instance()
{
@@ -179,7 +188,10 @@ TInt PjSymbianOS::Initialize()
return err;
#endif
- if (!isSocketServInitialized_) {
+ /* Only create RSocketServ if application doesn't specify it
+ * in the parameters
+ */
+ if (!isSocketServInitialized_ && appSocketServ_ == NULL) {
err = socketServ_.Connect();
if (err != KErrNone)
goto on_error;
@@ -187,8 +199,13 @@ TInt PjSymbianOS::Initialize()
isSocketServInitialized_ = true;
}
- if (!isResolverInitialized_) {
- err = hostResolver_.Open(SocketServ(), KAfInet, KSockStream);
+ if (!isResolverInitialized_ && appHostResolver_ == NULL) {
+ if (Connection())
+ err = hostResolver_.Open(SocketServ(), KAfInet, KSockStream,
+ *Connection());
+ else
+ err = hostResolver_.Open(SocketServ(), KAfInet, KSockStream);
+
if (err != KErrNone)
goto on_error;
@@ -260,6 +277,15 @@ PJ_DEF(pj_uint32_t) pj_getpid(void)
}
+/* Set Symbian specific parameters */
+PJ_DEF(pj_status_t) pj_symbianos_set_params(pj_symbianos_params *prm)
+{
+ PJ_ASSERT_RETURN(prm != NULL, PJ_EINVAL);
+ PjSymbianOS::Instance()->SetParameters(prm);
+ return PJ_SUCCESS;
+}
+
+
/*
* pj_init(void).
* Init PJLIB!
diff --git a/pjlib/src/pj/os_symbian.h b/pjlib/src/pj/os_symbian.h
index 5fabdc6e..2b14ecd6 100644
--- a/pjlib/src/pj/os_symbian.h
+++ b/pjlib/src/pj/os_symbian.h
@@ -20,6 +20,7 @@
#define __OS_SYMBIAN_H__
#include <pj/sock.h>
+#include <pj/os.h>
#include <pj/string.h>
#include <e32base.h>
@@ -195,6 +196,11 @@ public:
static PjSymbianOS *Instance();
//
+ // Set parameters
+ //
+ void SetParameters(pj_symbianos_params *params);
+
+ //
// Initialize.
//
TInt Initialize();
@@ -212,9 +218,15 @@ public:
// Get RSocketServ instance to be used by all sockets.
RSocketServ &SocketServ()
{
- return socketServ_;
+ return appSocketServ_ ? *appSocketServ_ : socketServ_;
}
+ // Get RConnection instance, if any.
+ RConnection *Connection()
+ {
+ return appConnection_;
+ }
+
// Convert TInetAddr to pj_sockaddr_in
static inline void Addr2pj(const TInetAddr & sym_addr,
pj_sockaddr_in &pj_addr)
@@ -243,7 +255,7 @@ public:
// Get RHostResolver instance
RHostResolver & GetResolver()
{
- return hostResolver_;
+ return appHostResolver_ ? *appHostResolver_ : hostResolver_;
}
@@ -296,6 +308,11 @@ private:
CPjTimeoutTimer *selectTimeoutTimer_;
+ // App parameters
+ RSocketServ *appSocketServ_;
+ RConnection *appConnection_;
+ RHostResolver *appHostResolver_;
+
private:
PjSymbianOS();
};
diff --git a/pjlib/src/pj/sock_symbian.cpp b/pjlib/src/pj/sock_symbian.cpp
index 7c7680a9..4a1da7be 100644
--- a/pjlib/src/pj/sock_symbian.cpp
+++ b/pjlib/src/pj/sock_symbian.cpp
@@ -474,7 +474,14 @@ PJ_DEF(pj_status_t) pj_sock_socket(int af,
/* Create Symbian RSocket */
RSocket rSock;
- rc = rSock.Open(PjSymbianOS::Instance()->SocketServ(), af, type, proto);
+ if (PjSymbianOS::Instance()->Connection())
+ rc = rSock.Open(PjSymbianOS::Instance()->SocketServ(),
+ af, type, proto,
+ *PjSymbianOS::Instance()->Connection());
+ else
+ rc = rSock.Open(PjSymbianOS::Instance()->SocketServ(),
+ af, type, proto);
+
if (rc != KErrNone)
return PJ_RETURN_OS_ERROR(rc);