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>2007-11-01 22:11:55 +0300
committerEion Robb <eion@robbmob.com>2007-11-01 22:11:55 +0300
commit474952053bb2c6f060e0e66e2ca0a6f9bad4a260 (patch)
tree13829e64a825af030e694c8e4515cbee6a7cd8d6 /skype_messaging_carbon.c
Diffstat (limited to 'skype_messaging_carbon.c')
-rw-r--r--skype_messaging_carbon.c109
1 files changed, 109 insertions, 0 deletions
diff --git a/skype_messaging_carbon.c b/skype_messaging_carbon.c
new file mode 100644
index 0000000..85fec76
--- /dev/null
+++ b/skype_messaging_carbon.c
@@ -0,0 +1,109 @@
+#include <Carbon/Carbon.h>
+#include <Skype/Skype.h>
+#include <glib.h>
+#include <CoreFoundation/CoreFoundation.h>
+
+#define SENDSKYPERETURNS 1
+
+static gboolean connected_to_skype = FALSE;
+
+void SkypeNotificationReceived(CFStringRef input)
+{
+ printf("Message received\n");
+ char *output = CFStringGetCStringPtr(input, kCFStringEncodingUTF8);
+ if (!output)
+ {
+ output = NewPtr(CFStringGetLength(input)+1);
+ CFStringGetCString(input, output, CFStringGetLength(input)+1, kCFStringEncodingUTF8);
+ }
+
+ g_thread_create((GThreadFunc)skype_message_received, (void *)output, FALSE, NULL);
+}
+
+void SkypeAttachResponse(unsigned int aAttachResponseCode)
+{
+ if (aAttachResponseCode)
+ {
+ printf("Skype attached successfully :)\n");
+ connected_to_skype = TRUE;
+ }
+ else
+ {
+ printf("Skype couldn't connect :(\n");
+ connected_to_skype = FALSE;
+ }
+}
+
+void SkypeBecameAvailable(CFPropertyListRef aNotification)
+{
+ printf("Skype became available\n");
+ connected_to_skype = TRUE;
+}
+
+void SkypeBecameUnavailable(CFPropertyListRef aNotification)
+{
+ printf("Skype became unavailable\n");
+ connected_to_skype = FALSE;
+}
+
+static struct SkypeDelegate skypeDelegate = {
+ CFSTR("Adium"), /* clientAppName */
+ SkypeNotificationReceived,
+ SkypeAttachResponse,
+ SkypeBecameAvailable,
+ SkypeBecameUnavailable
+};
+
+static gboolean skype_connect_thread(gpointer data)
+{
+ printf("Start inner event loop\n");
+ RunApplicationEventLoop();
+ printf("End of event loop\n");
+
+ return FALSE;
+}
+
+static gboolean skype_connect()
+{
+ EventRef theEvent;
+ EventTargetRef theTarget;
+ EventRecord *eventRecord;
+ gboolean is_skype_running = FALSE;
+
+ is_skype_running = IsSkypeRunning();
+
+ printf("Is Skype running? '%s'\n", is_skype_running?"Yes":"No");
+ if (!is_skype_running)
+ return FALSE;
+
+ SetSkypeDelegate(&skypeDelegate);
+ ConnectToSkype();
+
+ g_thread_create((GThreadFunc)skype_connect_thread, NULL, FALSE, NULL);
+ while(connected_to_skype == FALSE)
+ {
+ RunCurrentEventLoop(1);
+ }
+ printf("Connected to skype\n");
+ return TRUE;
+}
+
+static void skype_disconnect()
+{
+ DisconnectFromSkype();
+ RemoveSkypeDelegate();
+ RunCurrentEventLoop(1);
+}
+
+static void send_message(char* message)
+{
+ printf("Skype send message\n");
+#if SENDSKYPERETURNS
+ CFStringRef returnString;
+ returnString = SendSkypeCommand(CFStringCreateWithCString(NULL, message, kCFStringEncodingUTF8));
+ if (returnString)
+ SkypeNotificationReceived(returnString);
+#else
+ SendSkypeCommand(CFStringCreateWithCString(NULL, message, kCFStringEncodingUTF8));
+#endif
+}