forked from EionRobb/skype4pidgin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SkypePlugin.m
93 lines (76 loc) · 3.02 KB
/
SkypePlugin.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
//
// SkypePlugin.m
// SkypePlugin
//
// Created by Eion Robb on 14/10/07.
//
#import "SkypePlugin.h"
#import "PurpleSkypeAccount.h"
#import "PurpleSkypeService.h"
#import <AdiumLibpurple/adiumPurpleFt.h>
#import <AdiumLibpurple/adiumPurpleEventloop.h>
#import <Adium/ESFileTransfer.h>
#import <libpurple/libpurple.h>
#include <dlfcn.h>
extern PurplePlugin *purple_plugin_new(gboolean native, const char *path) __attribute__((weak_import));
//extern void g_thread_init (GThreadFunctions *vtable) __attribute__((weak_import));
guint (*adium_timeout_add)(guint, GSourceFunc, gpointer);
gboolean purple_init_skype_plugin(void);
static void skypeAdiumPurpleAddXfer(PurpleXfer *xfer)
{
if (!xfer || !xfer->account || strcmp(xfer->account->protocol_id, "prpl-bigbrownchunx-skype"))
return;
ESFileTransfer *fileTransfer;
//Ask the account for an ESFileTransfer* object
fileTransfer = [accountLookup(xfer->account) newFileTransferObjectWith:[NSString stringWithUTF8String:(xfer->who)]
size:purple_xfer_get_size(xfer)
remoteFilename:[NSString stringWithUTF8String:(xfer->filename)]];
//Configure the new object for the transfer
[fileTransfer setAccountData:[NSValue valueWithPointer:xfer]];
xfer->ui_data = [fileTransfer retain];
}
guint adium_threadsafe_timeout_add(guint interval, GSourceFunc function, gpointer data)
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
guint return_val = adium_timeout_add(interval, function, data);
[pool release];
return return_val;
}
@implementation SkypePlugin
- (void)installPlugin
{
printf("Installing SkypePlugin\n");
//Check that we can thread stuff
if (dlsym(RTLD_DEFAULT, "g_thread_init") == NULL)
{
printf("No g_thread_init();\n");
//try opening thread libraries
dlopen("~/Library/Application Support/Adium 2.0/PlugIns/SkypePlugin.AdiumLibpurplePlugin/Contents/Libraries/libgthread-2.0.0.dylib", RTLD_LAZY);
if (dlsym(RTLD_DEFAULT, "g_thread_init") == NULL)
{
printf("Can't load GThread :(\n");
return;
}
}
printf("Calling purple_init_skype_plugin()\n");
//Hack in our own transfer code and thread-safe timeout loop
adium_purple_xfers_get_ui_ops()->add_xfer = skypeAdiumPurpleAddXfer;
//adium_timeout_add = adium_purple_eventloop_get_ui_ops()->timeout_add;
//adium_purple_eventloop_get_ui_ops()->timeout_add = adium_threadsafe_timeout_add;
#ifdef ENABLE_NLS
//bindtextdomain("pidgin", [[[NSBundle bundleWithIdentifier:@"im.pidgin.libpurple"] resourcePath] fileSystemRepresentation]);
//bind_textdomain_codeset("pidgin", "UTF-8");
//textdomain("pidgin");
bindtextdomain("skype4pidgin", [[[[NSBundle bundleWithIdentifier:@"org.bigbrownchunx.skypeplugin"] resourcePath] stringByAppendingPathComponent:@"/locale"] fileSystemRepresentation]);
bind_textdomain_codeset("skype4pidgin", "UTF-8");
textdomain("skype4pidgin");
#endif
purple_init_skype_plugin();
printf("Initialising PurpleSkypeService\n");
SkypeService = [[PurpleSkypeService alloc] init];
}
- (void)uninstallPlugin
{
[SkypeService release]; SkypeService = nil;
}
@end