adium 5020:8adf47ae7b50: Wrap all C functions in adiumPurpleSign...
commits at adium.im
commits at adium.im
Wed Sep 5 20:34:59 UTC 2012
details: http://hg.adium.im/adium/rev/8adf47ae7b50
revision: 5020:8adf47ae7b50
branch: adium-1.5.4
author: Thijs Alkemade <thijsalkemade at gmail.com>
date: Wed Sep 05 22:34:50 2012 +0200
Wrap all C functions in adiumPurpleSignals and all C callbacks in AdiumOTREncryption in autoreleasepools.
diffs (393 lines):
diff -r 89b86d3ffe84 -r 8adf47ae7b50 Plugins/Purple Service/adiumPurpleSignals.m
--- a/Plugins/Purple Service/adiumPurpleSignals.m Wed Sep 05 22:00:03 2012 +0200
+++ b/Plugins/Purple Service/adiumPurpleSignals.m Wed Sep 05 22:34:50 2012 +0200
@@ -27,6 +27,8 @@
static void buddy_event_cb(PurpleBuddy *buddy, PurpleBuddyEvent event)
{
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+
if (buddy) {
SEL updateSelector = nil;
id data = nil;
@@ -121,10 +123,13 @@
}
}
}
+
+ [pool release];
}
static void buddy_status_changed_cb(PurpleBuddy *buddy, PurpleStatus *oldstatus, PurpleStatus *status, PurpleBuddyEvent event)
{
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
CBPurpleAccount *account = accountLookup(purple_buddy_get_account(buddy));
AIListContact *theContact = contactLookupFromBuddy(buddy);
NSNumber *statusTypeNumber;
@@ -148,10 +153,12 @@
statusName:statusName
statusMessage:statusMessage
isMobile:isMobile];
+ [pool release];
}
static void buddy_idle_changed_cb(PurpleBuddy *buddy, gboolean old_idle, gboolean idle, PurpleBuddyEvent event)
{
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
CBPurpleAccount *account = accountLookup(purple_buddy_get_account(buddy));
AIListContact *theContact = contactLookupFromBuddy(buddy);
PurplePresence *presence = purple_buddy_get_presence(buddy);
@@ -167,11 +174,14 @@
[account updateIdleReturn:theContact
withData:nil];
}
+
+ [pool release];
}
//This is called when a buddy is added or changes groups
static void buddy_added_cb(PurpleBuddy *buddy)
{
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
PurpleAccount *purpleAccount = purple_buddy_get_account(buddy);
if (purple_account_is_connected(purpleAccount)) {
CBPurpleAccount *account = accountLookup(purpleAccount);
@@ -202,10 +212,12 @@
// Force a status update for the user. Useful for things like XMPP which might display an error message for an offline contact.
buddy_status_changed_cb(buddy, NULL, purple_presence_get_active_status(purple_buddy_get_presence(buddy)), PURPLE_BUDDY_NONE);
}
+ [pool release];
}
static void buddy_removed_cb(PurpleBuddy *buddy)
{
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
PurpleAccount *purpleAccount = purple_buddy_get_account(buddy);
if (purple_account_is_connected(purpleAccount)) {
CBPurpleAccount *account = accountLookup(purpleAccount);
@@ -219,20 +231,25 @@
*/
[account removeContact:listContact fromGroupName:groupName];
}
+ [pool release];
}
static void connection_signed_on_cb(PurpleConnection *gc)
{
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
GSList *buddies = purple_find_buddies(purple_connection_get_account(gc), /* buddy_name */ NULL);
GSList *cur;
for (cur = buddies; cur; cur = cur->next) {
buddy_added_cb((PurpleBuddy *)cur->data);
}
g_slist_free(buddies);
+
+ [pool release];
}
static void node_aliased_cb(PurpleBlistNode *node, char *old_alias)
{
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
if (PURPLE_BLIST_NODE_IS_BUDDY(node)) {
PurpleBuddy *buddy = (PurpleBuddy *)node;
CBPurpleAccount *account = accountLookup(purple_buddy_get_account(buddy));
@@ -247,6 +264,8 @@
[account updateContact:contactLookupFromBuddy(buddy)
toAlias:(alias ? [NSString stringWithUTF8String:alias] : nil)];
}
+
+ [pool release];
}
static NSDictionary *dictionaryFromHashTable(GHashTable *data)
@@ -273,6 +292,7 @@
static void chat_join_failed_cb(PurpleConnection *gc, GHashTable *components)
{
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
CBPurpleAccount *account = accountLookup(purple_connection_get_account(gc));
NSDictionary *componentDict = dictionaryFromHashTable(components);
@@ -283,10 +303,13 @@
break;
}
}
+
+ [pool release];
}
static void typing_changed(PurpleAccount *account, const char *name, AITypingState typingState)
{
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
CBPurpleAccount *cbaccount = accountLookup(account);
AIListContact *contact = contactLookupFromBuddy(purple_find_buddy(account, name));
@@ -304,14 +327,18 @@
if (chat)
[cbaccount typingUpdateForIMChat:chat typing:[NSNumber numberWithInteger:typingState]];
+
+ [pool release];
}
static void conversation_created_cb(PurpleConversation *conv, void *data) {
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM) {
AIChat *chat = imChatLookupFromConv(conv);
//When a conversation is created, we must clear the typing flag, as libpurple won't notify us properly
[accountLookup(purple_conversation_get_account(conv)) typingUpdateForIMChat:chat typing:[NSNumber numberWithInteger:AINotTyping]];
}
+ [pool release];
}
/* The buddy-typing, buddy-typed, and buddy-typing-stopped signals will only be sent
@@ -337,19 +364,23 @@
static void
chat_joined_cb(PurpleConversation *conv, void *data) {
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
//Pass chats along to the account
if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT) {
AIChat *chat = groupChatLookupFromConv(conv);
[accountLookup(purple_conversation_get_account(conv)) addChat:chat];
- }
+ }
+
+ [pool release];
}
static void
file_recv_request_cb(PurpleXfer *xfer)
{
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
ESFileTransfer *fileTransfer;
//Purple doesn't return normalized user id, so it should be normalized manually
@@ -374,10 +405,13 @@
//Tell the account that we are ready to request the reception
[accountLookup(purple_xfer_get_account(xfer)) requestReceiveOfFileTransfer:fileTransfer];
+
+ [pool release];
}
void configureAdiumPurpleSignals(void)
{
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
void *blist_handle = purple_blist_get_handle();
void *handle = adium_purple_get_handle();
@@ -448,4 +482,6 @@
purple_signal_connect(purple_xfers_get_handle(), "file-recv-request",
handle, PURPLE_CALLBACK(file_recv_request_cb), NULL);
+
+ [pool release];
}
diff -r 89b86d3ffe84 -r 8adf47ae7b50 Source/AdiumOTREncryption.m
--- a/Source/AdiumOTREncryption.m Wed Sep 05 22:00:03 2012 +0200
+++ b/Source/AdiumOTREncryption.m Wed Sep 05 22:34:50 2012 +0200
@@ -400,7 +400,9 @@
static void create_privkey_cb(void *opdata, const char *accountname,
const char *protocol)
{
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
otrg_plugin_create_privkey(accountname, protocol);
+ [pool release];
}
/* Report whether you think the given user is online. Return 1 if
@@ -412,20 +414,29 @@
static int is_logged_in_cb(void *opdata, const char *accountname,
const char *protocol, const char *recipient)
{
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+
AIListContact *contact = contactFromInfo(accountname, protocol, recipient);
+ int ret;
if ([contact statusSummary] == AIUnknownStatus)
- return -1;
+ ret = -1;
else
- return (contact.online ? 1 : 0);
+ ret = (contact.online ? 1 : 0);
+
+ [pool release];
+
+ return ret;
}
/* Send the given IM to the given recipient from the given
* accountname/protocol. */
static void inject_message_cb(void *opdata, const char *accountname,
const char *protocol, const char *recipient, const char *message)
-{
+{
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
[adium.contentController sendRawMessage:[NSString stringWithUTF8String:message]
toContact:contactFromInfo(accountname, protocol, recipient)];
+ [pool release];
}
/*!
@@ -517,6 +528,7 @@
const char *accountname, const char *protocol, const char *username,
const char *title, const char *primary, const char *secondary)
{
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
AIListContact *listContact = contactFromInfo(accountname, protocol, username);
NSString *displayName = listContact.displayName;
@@ -529,6 +541,7 @@
secondary:[adiumOTREncryption localizedOTRMessage:[NSString stringWithUTF8String:secondary]
withUsername:displayName
isWorthOpeningANewChat:NULL]];
+ [pool release];
}
/* Display an OTR control message for a particular accountname /
@@ -540,21 +553,36 @@
static int display_otr_message_cb(void *opdata, const char *accountname,
const char *protocol, const char *username, const char *msg)
{
- return display_otr_message(accountname, protocol, username, msg);
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+ int ret = display_otr_message(accountname, protocol, username, msg);
+
+ [pool release];
+
+ return ret;
}
/* When the list of ConnContexts changes (including a change in
* state), this is called so the UI can be updated. */
static void update_context_list_cb(void *opdata)
{
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+
otrg_ui_update_keylist();
+
+ [pool release];
}
/* Return a newly allocated string containing a human-friendly
* representation for the given account */
static const char *account_display_name_cb(void *opdata, const char *accountname, const char *protocol)
{
- return strdup([[accountFromAccountID(accountname) formattedUID] UTF8String]);
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+
+ const char *ret = strdup([[accountFromAccountID(accountname) formattedUID] UTF8String]);
+
+ [pool release];
+
+ return ret;
}
/* Deallocate a string returned by account_name */
@@ -568,7 +596,12 @@
* for the given protocol id */
static const char *protocol_name_cb(void *opdata, const char *protocol)
{
- return strdup([[serviceFromServiceID(protocol) shortDescription] UTF8String]);
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+ const char *ret = strdup([[serviceFromServiceID(protocol) shortDescription] UTF8String]);
+
+ [pool release];
+
+ return ret;
}
/* Deallocate a string allocated by protocol_name */
@@ -584,6 +617,7 @@
const char *accountname, const char *protocol, const char *username,
unsigned char fingerprint[20])
{
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
ConnContext *context;
context = otrl_context_find(us, username, accountname,
@@ -597,6 +631,7 @@
[adiumOTREncryption performSelector:@selector(verifyUnknownFingerprint:)
withObject:[NSValue valueWithPointer:context]
afterDelay:0];
+ [pool release];
}
/* The list of known fingerprints has changed. Write them to disk. */
@@ -608,35 +643,50 @@
/* A ConnContext has entered a secure state. */
static void gone_secure_cb(void *opdata, ConnContext *context)
{
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
AIChat *chat = chatForContext(context);
update_security_details_for_chat(chat);
otrg_ui_update_fingerprint();
+
+ [pool release];
}
/* A ConnContext has left a secure state. */
static void gone_insecure_cb(void *opdata, ConnContext *context)
{
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+
AIChat *chat = chatForContext(context);
update_security_details_for_chat(chat);
otrg_ui_update_fingerprint();
+
+ [pool release];
}
/* We have completed an authentication, using the D-H keys we
* already knew. is_reply indicates whether we initiated the AKE. */
static void still_secure_cb(void *opdata, ConnContext *context, int is_reply)
{
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+
if (is_reply == 0) {
// otrg_dialog_stillconnected(context);
AILog(@"Still secure...");
}
+
+ [pool release];
}
/* Log a message. The passed message will end in "\n". */
static void log_message_cb(void *opdata, const char *message)
{
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+
AILog(@"otr: %s", (message ? message : "(null)"));
+
+ [pool release];
}
/*!
@@ -653,6 +703,8 @@
*/
int max_message_size_cb(void *opdata, ConnContext *context)
{
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+
AIChat *chat = chatForContext(context);
/* Values from http://www.cypherpunks.ca/otr/UPGRADING-libotr-3.1.0.txt */
@@ -670,7 +722,11 @@
/* This will return 0 if we don't know (unknown protocol) or don't need it (Jabber),
* which will disable fragmentation.
*/
- return [[maxSizeByServiceClassDict objectForKey:chat.account.service.serviceClass] intValue];
+ int ret = [[maxSizeByServiceClassDict objectForKey:chat.account.service.serviceClass] intValue];
+
+ [pool release];
+
+ return ret;
}
static OtrlMessageAppOps ui_ops = {
More information about the commits
mailing list