Added silc_schedule_[set|get]_global. Added many APIs to call
[crypto.git] / lib / silcutil / symbian / silcsymbiannet.cpp
index 1895b1dda42aa80fe923ef239d5a1227bc7d475b..c665b3d339632fb6655a6b0484f2e726c1e1def3 100644 (file)
@@ -181,8 +181,18 @@ silc_net_tcp_create_listener(const char **local_ip_addr,
 
   SILC_LOG_DEBUG(("Creating TCP listener"));
 
-  if (port < 0 || !schedule || !callback)
+  if (!schedule) {
+    schedule = silc_schedule_get_global();
+    if (!schedule) {
+      silc_set_errno(SILC_ERR_INVALID_ARGUMENT);
+      goto err;
+    }
+  }
+
+  if (port < 0 || !callback) {
+    silc_set_errno(SILC_ERR_INVALID_ARGUMENT);
     goto err;
+  }
 
   listener = (SilcNetListener)silc_calloc(1, sizeof(*listener));
   if (!listener) {
@@ -301,8 +311,18 @@ silc_net_tcp_create_listener2(const char *local_ip_addr, int *ports,
 
   SILC_LOG_DEBUG(("Creating TCP listener"));
 
-  if (!schedule || !callback)
+  if (!schedule) {
+    schedule = silc_schedule_get_global();
+    if (!schedule) {
+      silc_set_errno(SILC_ERR_INVALID_ARGUMENT);
+      goto err;
+    }
+  }
+
+  if (!callback) {
+    silc_set_errno(SILC_ERR_INVALID_ARGUMENT);
     goto err;
+  }
 
   listener = (SilcNetListener)silc_calloc(1, sizeof(*listener));
   if (!listener) {
@@ -600,8 +620,18 @@ SilcAsyncOperation silc_net_tcp_connect(const char *local_ip_addr,
   SilcResult status;
   TInt ret;
 
-  if (!remote_ip_addr || remote_port < 1 || !schedule || !callback)
+  if (!schedule) {
+    schedule = silc_schedule_get_global();
+    if (!schedule) {
+      silc_set_errno(SILC_ERR_INVALID_ARGUMENT);
+      return NULL;
+    }
+  }
+
+  if (!remote_ip_addr || remote_port < 1 || !callback) {
+    silc_set_errno(SILC_ERR_INVALID_ARGUMENT);
     return NULL;
+  }
 
   SILC_LOG_DEBUG(("Creating connection to host %s port %d",
                  remote_ip_addr, remote_port));
@@ -727,8 +757,13 @@ SilcStream silc_net_udp_connect(const char *local_ip_addr, int local_port,
 
   SILC_LOG_DEBUG(("Creating UDP stream"));
 
-  if (!schedule)
-    goto err;
+  if (!schedule) {
+    schedule = silc_schedule_get_global();
+    if (!schedule) {
+      silc_set_errno(SILC_ERR_INVALID_ARGUMENT);
+      goto err;
+    }
+  }
 
   SILC_LOG_DEBUG(("Binding to local address %s",
                  local_ip_addr ? local_ip_addr : "0.0.0.0"));