Permalink
Browse files

voip can be enabled

  • Loading branch information...
dinhviethoa committed Dec 5, 2011
1 parent 349fd78 commit 4d82df9fc1c10d47f4f9ce4db591b967634c533a
Showing with 26 additions and 0 deletions.
  1. +25 −0 src/data-types/mailstream_cfstream.c
  2. +1 −0 src/data-types/mailstream_cfstream.h
@@ -180,6 +180,9 @@ mailstream * mailstream_cfstream_open(const char * hostname, int16_t port)
mailstream * s;
low = mailstream_low_cfstream_open(hostname, port);
+ if (low == NULL) {
+ return NULL;
+ }
s = mailstream_new(low, 8192);
return s;
#else
@@ -435,6 +438,10 @@ mailstream_low * mailstream_low_cfstream_open(const char * hostname, int16_t por
cfstream_data->cancelSource = CFRunLoopSourceCreate(NULL, 0, &cfstream_data->cancelContext);
r = low_open(s);
+ if (r < 0) {
+ mailstream_low_cfstream_close(s);
+ return NULL;
+ }
return s;
#else
@@ -1003,3 +1010,21 @@ void mailstream_cfstream_interrupt_idle(mailstream * s)
pthread_mutex_unlock(&cfstream_data->runloop_lock);
#endif
}
+
+void mailstream_cfstream_set_voip_enabled(mailstream * s, int enabled)
+{
+ struct mailstream_cfstream_data * cfstream_data;
+
+ cfstream_data = (struct mailstream_cfstream_data *) s->low->data;
+
+#if TARGET_OS_IPHONE && !TARGET_IPHONE_SIMULATOR
+ if (enabled) {
+ CFReadStreamSetProperty(cfstream_data->readStream, kCFStreamNetworkServiceType, kCFStreamNetworkServiceTypeVoIP);
+ CFWriteStreamSetProperty(cfstream_data->writeStream, kCFStreamNetworkServiceType, kCFStreamNetworkServiceTypeVoIP);
+ }
+ else {
+ CFReadStreamSetProperty(cfstream_data->readStream, kCFStreamNetworkServiceType, NULL);
+ CFWriteStreamSetProperty(cfstream_data->writeStream, kCFStreamNetworkServiceType, NULL);
+ }
+#endif
+}
@@ -88,6 +88,7 @@ extern "C" {
void mailstream_cfstream_interrupt_idle(mailstream * s);
void mailstream_cfstream_unsetup_idle(mailstream * s);
+ void mailstream_cfstream_set_voip_enabled(mailstream * s, int enabled);
#ifdef __cplusplus
}
#endif

0 comments on commit 4d82df9

Please sign in to comment.