Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/EionRobb/skype4pidgin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEion Robb <eion@robbmob.com>2008-07-15 02:28:30 +0400
committerEion Robb <eion@robbmob.com>2008-07-15 02:28:30 +0400
commit825145c9df109da049f77710ab25d4e3f7b429f6 (patch)
treeb692a30d4b5a429f7fef8c5270e7b55756dfd345 /skype_messaging_network.c
parenta1e45441e7eee8696cc03691285505e5af686bb9 (diff)
Add networking to compile option
Diffstat (limited to 'skype_messaging_network.c')
-rw-r--r--skype_messaging_network.c39
1 files changed, 25 insertions, 14 deletions
diff --git a/skype_messaging_network.c b/skype_messaging_network.c
index 93ce060..a4be73f 100644
--- a/skype_messaging_network.c
+++ b/skype_messaging_network.c
@@ -2,7 +2,7 @@
static PurpleProxyConnectData *proxy_data = NULL;
static guint input_timeout;
-static gint source_sock;
+static gint source_sock = -1;
void
read_function_cb(gpointer data, gint source, PurpleInputCondition cond)
@@ -16,7 +16,8 @@ read_function_cb(gpointer data, gint source, PurpleInputCondition cond)
{
if (errno != EAGAIN && errno != EWOULDBLOCK)
{
- close(source);
+ close(source);
+ source = -1;
purple_input_remove(input_timeout);
}
return;
@@ -24,12 +25,14 @@ read_function_cb(gpointer data, gint source, PurpleInputCondition cond)
if (len != 0)
{
if (response_string == NULL)
- response_string = g_string_new_len(response, len);
+ response_string = g_string_new_len(response, len);
+ else
+ response_string = g_string_append_len(response_string, response, len);
}
if (len == 0)
{
-
- g_thread_create((GThreadFunc)skype_message_received, g_strdup(response), FALSE, NULL);
+ g_thread_create((GThreadFunc)skype_message_received, g_string_free(response_string, FALSE), FALSE, NULL);
+ response_string = NULL;
}
}
@@ -60,22 +63,30 @@ skype_connect()
static void
skype_disconnect()
{
-
+ close(source);
+ source = -1;
+ purple_input_remove(input_timeout);
}
static void
send_message(char* message)
{
int message_num;
- char *error_return;
-
- //There was an error
- if (message[0] == '#')
+ char *error_return;
+ int strlen = strlen(message);
+ int len;
+
+ len = write(source, message, strlen);
+ if (len != strlen)
{
- //And we're expecting a response
- sscanf(message, "#%d ", &message_num);
- error_return = g_strdup_printf("#%d ERROR NETWORK", message_num);
- g_thread_create((GThreadFunc)skype_message_received, (void *)error_return, FALSE, NULL);
+ //There was an error
+ if (message[0] == '#')
+ {
+ //And we're expecting a response
+ sscanf(message, "#%d ", &message_num);
+ error_return = g_strdup_printf("#%d ERROR NETWORK", message_num);
+ g_thread_create((GThreadFunc)skype_message_received, (void *)error_return, FALSE, NULL);
+ }
}
}