Plugins/Purple Service/SLPurpleCocoaAdapter.m
author Evan Schoenberg
Sun, 21 Aug 2011 15:14:33 -0500
changeset 3610 93c8292bc1c8
parent 3608 c5435740e49b
permissions -rw-r--r--
Apply the same fix as a00b7964253b, but for group chats, again resolving a double-retain
(transplanted from a9560a8f30eb8e61e4a327d42b5376262ad7e30b)
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
     1
/* 
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
     2
 * Adium is the legal property of its developers, whose names are listed in the copyright file included
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
     3
 * with this source distribution.
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
     4
 * 
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify it under the terms of the GNU
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
     6
 * General Public License as published by the Free Software Foundation; either version 2 of the License,
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
     7
 * or (at your option) any later version.
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
     8
 * 
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    10
 * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    11
 * Public License for more details.
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    12
 * 
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    13
 * You should have received a copy of the GNU General Public License along with this program; if not,
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    14
 * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    15
 */
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    16
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    17
#import <AdiumLibpurple/SLPurpleCocoaAdapter.h>
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    18
#import "CBPurpleAccount.h"
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    19
#import "CBPurpleServicePlugin.h"
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    20
#import "adiumPurpleCore.h"
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    21
#import "adiumPurpleEventloop.h"
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    22
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    23
#import <Adium/AIAccountControllerProtocol.h>
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    24
#import <Adium/AIInterfaceControllerProtocol.h>
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    25
#import <Adium/AILoginControllerProtocol.h>
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    26
#import <AIUtilities/AIObjectAdditions.h>
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    27
#import <Adium/AIAccount.h>
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    28
#import <Adium/AICorePluginLoader.h>
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    29
#import <Adium/AIService.h>
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    30
#import <Adium/AIChat.h>
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    31
#import <Adium/AIContentTyping.h>
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    32
#import <Adium/AIHTMLDecoder.h>
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    33
#import <Adium/AIListContact.h>
3161
c959997fcffb Delay list object notifications as libpurple initializes; it can be expensive in terms of adding contacts from the permit and deny lists. Also, include a delayListObjectNotificationsUntilInactivity call as a few behaviors occur on the next runloop
Evan Schoenberg
parents: 3083
diff changeset
    34
#import <Adium/AIContactObserverManager.h>
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    35
#import <Adium/AIUserIcons.h>
3197
700131f4c0b6 Fix a localization problem in which these substituted error messages wouldn't be shown in their localized form
Evan Schoenberg
parents: 3161
diff changeset
    36
#import <Adium/AIContactObserverManager.h>
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    37
#import <AIUtilities/AIImageAdditions.h>
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    38
558
0233e28929e8 Eliminate a bunch of unnecessary imports
David Smith
parents: 475
diff changeset
    39
#import <CoreFoundation/CoreFoundation.h>
2093
d470a05e220b I see no reason to not use #import for everything. Apple's compiler supports it fine in .c files, and it doesn't seem to have any downsides vs #include unless you're playing silly multiple inclusion tricks
David Smith <catfish.man@gmail.com>
parents: 2018
diff changeset
    40
#import <libpurple/libpurple.h>
d470a05e220b I see no reason to not use #import for everything. Apple's compiler supports it fine in .c files, and it doesn't seem to have any downsides vs #include unless you're playing silly multiple inclusion tricks
David Smith <catfish.man@gmail.com>
parents: 2018
diff changeset
    41
#import <glib.h>
d470a05e220b I see no reason to not use #import for everything. Apple's compiler supports it fine in .c files, and it doesn't seem to have any downsides vs #include unless you're playing silly multiple inclusion tricks
David Smith <catfish.man@gmail.com>
parents: 2018
diff changeset
    42
#import <stdlib.h>
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    43
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    44
#import "ESPurpleAIMAccount.h"
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    45
#import "CBPurpleOscarAccount.h"
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    46
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    47
#import "ESiTunesPlugin.h"
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    48
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    49
#import "adiumPurpleAccounts.h"
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    50
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    51
//Purple slash command interface
2093
d470a05e220b I see no reason to not use #import for everything. Apple's compiler supports it fine in .c files, and it doesn't seem to have any downsides vs #include unless you're playing silly multiple inclusion tricks
David Smith <catfish.man@gmail.com>
parents: 2018
diff changeset
    52
#import <libpurple/cmds.h>
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    53
2093
d470a05e220b I see no reason to not use #import for everything. Apple's compiler supports it fine in .c files, and it doesn't seem to have any downsides vs #include unless you're playing silly multiple inclusion tricks
David Smith <catfish.man@gmail.com>
parents: 2018
diff changeset
    54
#import "libpurple_extensions/oscar-adium.h"
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    55
84
3b5f51e77592 Switch all of our private method categories over to the new objc way of doing it (documented at http://developer.apple.com/documentation/Cocoa/Conceptual/ObjectiveC/Articles/chapter_4_section_5.html#//apple_ref/doc/uid/TP30001163-CH20-SW2). This enforces having implementations for them, and in the process turned up a vast number of methods we had deleted the impl for but not the declaration. loc -= 198;
David Smith
parents: 0
diff changeset
    56
@interface SLPurpleCocoaAdapter ()
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    57
- (void)initLibPurple;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    58
- (BOOL)attemptPurpleCommandOnMessage:(NSString *)originalMessage fromAccount:(AIAccount *)sourceAccount inChat:(AIChat *)chat;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    59
@end
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    60
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    61
/*
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    62
 * A pointer to the single instance of this class active in the application.
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    63
 * The purple callbacks need to be C functions with specific prototypes, so they
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    64
 * can't be ObjC methods. The ObjC callbacks do need to be ObjC methods. This
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    65
 * allows the C ones to call the ObjC ones.
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    66
 **/
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    67
static SLPurpleCocoaAdapter	*sharedInstance = nil;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    68
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    69
static NSMutableArray		*libpurplePluginArray = nil;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    70
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    71
@implementation SLPurpleCocoaAdapter
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    72
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    73
/*!
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    74
 * @brief Return the shared instance
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    75
 */
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    76
+ (SLPurpleCocoaAdapter *)sharedInstance
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    77
{	
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    78
	@synchronized(self) {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    79
		if (!sharedInstance) {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    80
			sharedInstance = [[self alloc] init];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    81
		}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    82
	}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    83
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    84
	return sharedInstance;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    85
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    86
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    87
/*!
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    88
 * @brief Plugin loaded
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    89
 *
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    90
 * Initialize each libpurple plugin.  These plugins should not do anything within libpurple itself; this should be done in
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    91
 * -[plugin initLibpurplePlugin].
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    92
 */
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    93
+ (void)pluginDidLoad
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    94
{
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    95
	libpurplePluginArray = [[NSMutableArray alloc] init];
166
a43b4310ef2a Updated most of our enumerations to fast enumerations, and did some paramaterization.
Evan Schoenberg
parents: 100
diff changeset
    96
a43b4310ef2a Updated most of our enumerations to fast enumerations, and did some paramaterization.
Evan Schoenberg
parents: 100
diff changeset
    97
	for (NSString *libpurplePluginPath in [adium allResourcesForName:@"Plugins"
a43b4310ef2a Updated most of our enumerations to fast enumerations, and did some paramaterization.
Evan Schoenberg
parents: 100
diff changeset
    98
													  withExtensions:@"AdiumLibpurplePlugin"]) {
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    99
		[AICorePluginLoader loadPluginAtPath:libpurplePluginPath
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   100
							  confirmLoading:YES
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   101
								 pluginArray:libpurplePluginArray];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   102
	}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   103
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   104
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   105
+ (NSArray *)libpurplePluginArray
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   106
{
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   107
	return libpurplePluginArray;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   108
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   109
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   110
//Register the account purpleside in the purple thread
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   111
- (void)addAdiumAccount:(CBPurpleAccount *)adiumAccount
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   112
{
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   113
	//Note that purple_account_new() calls purple_accounts_find() first, returning an existing PurpleAccount if there is one.
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   114
	PurpleAccount *account = purple_account_new([adiumAccount purpleAccountName], [adiumAccount protocolPlugin]);
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   115
774
cc44f167d44a Slightly improve behavior when multiple accounts have the same service and UID. This doesn't fix things, though
Evan Schoenberg
parents: 721
diff changeset
   116
	if (account->ui_data) {
cc44f167d44a Slightly improve behavior when multiple accounts have the same service and UID. This doesn't fix things, though
Evan Schoenberg
parents: 721
diff changeset
   117
		[(CBPurpleAccount *)account->ui_data autorelease];
cc44f167d44a Slightly improve behavior when multiple accounts have the same service and UID. This doesn't fix things, though
Evan Schoenberg
parents: 721
diff changeset
   118
		[(CBPurpleAccount *)account->ui_data setPurpleAccount:nil];
cc44f167d44a Slightly improve behavior when multiple accounts have the same service and UID. This doesn't fix things, though
Evan Schoenberg
parents: 721
diff changeset
   119
	}
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   120
	account->ui_data = [adiumAccount retain];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   121
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   122
	[adiumAccount setPurpleAccount:account];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   123
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   124
	purple_accounts_add(account);
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   125
	purple_account_set_status_list(account, "offline", YES, NULL);
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   126
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   127
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   128
//Remove an account purpleside
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   129
- (void)removeAdiumAccount:(CBPurpleAccount *)adiumAccount
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   130
{
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   131
	PurpleAccount *account = accountLookupFromAdiumAccount(adiumAccount);
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   132
774
cc44f167d44a Slightly improve behavior when multiple accounts have the same service and UID. This doesn't fix things, though
Evan Schoenberg
parents: 721
diff changeset
   133
	if (account) {
cc44f167d44a Slightly improve behavior when multiple accounts have the same service and UID. This doesn't fix things, though
Evan Schoenberg
parents: 721
diff changeset
   134
		[(CBPurpleAccount *)account->ui_data release];
cc44f167d44a Slightly improve behavior when multiple accounts have the same service and UID. This doesn't fix things, though
Evan Schoenberg
parents: 721
diff changeset
   135
		account->ui_data = nil;
cc44f167d44a Slightly improve behavior when multiple accounts have the same service and UID. This doesn't fix things, though
Evan Schoenberg
parents: 721
diff changeset
   136
		
cc44f167d44a Slightly improve behavior when multiple accounts have the same service and UID. This doesn't fix things, though
Evan Schoenberg
parents: 721
diff changeset
   137
		purple_accounts_remove(account);
cc44f167d44a Slightly improve behavior when multiple accounts have the same service and UID. This doesn't fix things, though
Evan Schoenberg
parents: 721
diff changeset
   138
	}
cc44f167d44a Slightly improve behavior when multiple accounts have the same service and UID. This doesn't fix things, though
Evan Schoenberg
parents: 721
diff changeset
   139
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   140
	[adiumAccount setPurpleAccount:NULL];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   141
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   142
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   143
#pragma mark Initialization
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   144
- (id)init
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   145
{
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   146
	if ((self = [super init])) {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   147
		[self initLibPurple];		
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   148
	}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   149
	
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   150
    return self;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   151
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   152
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   153
static void ZombieKiller_Signal(int i)
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   154
{
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   155
	int status;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   156
	pid_t child_pid;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   157
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   158
	while ((child_pid = waitpid(-1, &status, WNOHANG)) > 0);
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   159
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   160
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   161
- (void)networkDidChange:(NSNotification *)inNotification
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   162
{
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   163
	purple_signal_emit(purple_network_get_handle(), "network-configuration-changed", NULL);
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   164
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   165
3200
f04d1fb6ef86 Enable debug logging at runtime as appropriate rather than at compile times. Refs #14465 (where it was noted that a user's debug log didn't contain any libpurple information).
Evan Schoenberg
parents: 3197
diff changeset
   166
- (void)debugLoggingIsEnabledDidChange:(NSNotification *)inNotification
f04d1fb6ef86 Enable debug logging at runtime as appropriate rather than at compile times. Refs #14465 (where it was noted that a user's debug log didn't contain any libpurple information).
Evan Schoenberg
parents: 3197
diff changeset
   167
{
3259
1750cad42407 Fixed debug logging not to go to Console
Evan Schoenberg
parents: 3200
diff changeset
   168
	configurePurpleDebugLogging();
3200
f04d1fb6ef86 Enable debug logging at runtime as appropriate rather than at compile times. Refs #14465 (where it was noted that a user's debug log didn't contain any libpurple information).
Evan Schoenberg
parents: 3197
diff changeset
   169
}
f04d1fb6ef86 Enable debug logging at runtime as appropriate rather than at compile times. Refs #14465 (where it was noted that a user's debug log didn't contain any libpurple information).
Evan Schoenberg
parents: 3197
diff changeset
   170
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   171
- (void)initLibPurple
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   172
{
3161
c959997fcffb Delay list object notifications as libpurple initializes; it can be expensive in terms of adding contacts from the permit and deny lists. Also, include a delayListObjectNotificationsUntilInactivity call as a few behaviors occur on the next runloop
Evan Schoenberg
parents: 3083
diff changeset
   173
	/* Initializing libpurple may result in loading a ton of buddies if our permit and deny lists are large; that, in
c959997fcffb Delay list object notifications as libpurple initializes; it can be expensive in terms of adding contacts from the permit and deny lists. Also, include a delayListObjectNotificationsUntilInactivity call as a few behaviors occur on the next runloop
Evan Schoenberg
parents: 3083
diff changeset
   174
	 * turn, would create and update a ton of contacts.
c959997fcffb Delay list object notifications as libpurple initializes; it can be expensive in terms of adding contacts from the permit and deny lists. Also, include a delayListObjectNotificationsUntilInactivity call as a few behaviors occur on the next runloop
Evan Schoenberg
parents: 3083
diff changeset
   175
	 */
c959997fcffb Delay list object notifications as libpurple initializes; it can be expensive in terms of adding contacts from the permit and deny lists. Also, include a delayListObjectNotificationsUntilInactivity call as a few behaviors occur on the next runloop
Evan Schoenberg
parents: 3083
diff changeset
   176
	[[AIContactObserverManager sharedManager] delayListObjectNotifications];
c959997fcffb Delay list object notifications as libpurple initializes; it can be expensive in terms of adding contacts from the permit and deny lists. Also, include a delayListObjectNotificationsUntilInactivity call as a few behaviors occur on the next runloop
Evan Schoenberg
parents: 3083
diff changeset
   177
	
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   178
	//Set the gaim user directory to be within this user's directory
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   179
	if (![[NSUserDefaults standardUserDefaults] boolForKey:@"Adium 1.0.3 moved to libpurple"]) {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   180
		//Remove old icons cache
475
aa64795f351e err, I was a bit overzealous on the search&destroy there. This should fix things
David Smith
parents: 474
diff changeset
   181
		[[NSFileManager defaultManager]  removeItemAtPath:[[[adium.loginController userDirectory] stringByAppendingPathComponent:@"libgaim"] stringByAppendingPathComponent:@"icons"]
474
707e689b67b8 More deprecation removal
David Smith
parents: 428
diff changeset
   182
												  error:NULL];
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   183
		
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   184
		//Update the rest
474
707e689b67b8 More deprecation removal
David Smith
parents: 428
diff changeset
   185
		[[NSFileManager defaultManager] moveItemAtPath:[[adium.loginController userDirectory] stringByAppendingPathComponent:@"libgaim"]
100
68210ab2807a sed is evil. All [adium *Controller]s are now adium.*Controller.
David Smith
parents: 95
diff changeset
   186
										  toPath:[[adium.loginController userDirectory] stringByAppendingPathComponent:@"libpurple"]
474
707e689b67b8 More deprecation removal
David Smith
parents: 428
diff changeset
   187
										 error:NULL];
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   188
		
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   189
		[[NSUserDefaults standardUserDefaults] setBool:YES
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   190
												forKey:@"Adium 1.0.3 moved to libpurple"];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   191
	}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   192
	
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   193
	//Set the purple user directory to be within this user's directory
100
68210ab2807a sed is evil. All [adium *Controller]s are now adium.*Controller.
David Smith
parents: 95
diff changeset
   194
	NSString	*purpleUserDir = [[adium.loginController userDirectory] stringByAppendingPathComponent:@"libpurple"];
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   195
	purple_util_set_user_dir([[purpleUserDir stringByExpandingTildeInPath] fileSystemRepresentation]);
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   196
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   197
	//Set the caches path
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   198
	purple_buddy_icons_set_cache_dir([[[adium cachesPath] stringByExpandingTildeInPath] fileSystemRepresentation]);
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   199
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   200
	/* Delete blist.xml once when 1.2.4 runs to clear out any old silliness, including improperly blocked Yahoo contacts */
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   201
	if (![[NSUserDefaults standardUserDefaults] boolForKey:@"Adium 1.2.4 deleted blist.xml"]) {
475
aa64795f351e err, I was a bit overzealous on the search&destroy there. This should fix things
David Smith
parents: 474
diff changeset
   202
		[[NSFileManager defaultManager] removeItemAtPath:
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   203
			[[[NSString stringWithUTF8String:purple_user_dir()] stringByAppendingPathComponent:@"blist"] stringByAppendingPathExtension:@"xml"]
474
707e689b67b8 More deprecation removal
David Smith
parents: 428
diff changeset
   204
												 error:NULL];
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   205
		[[NSUserDefaults standardUserDefaults] setBool:YES
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   206
												forKey:@"Adium 1.2.4 deleted blist.xml"];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   207
	}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   208
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   209
	purple_core_set_ui_ops(adium_purple_core_get_ops());
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   210
	purple_eventloop_set_ui_ops(adium_purple_eventloop_get_ui_ops());
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   211
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   212
	//Initialize the libpurple core; this will call back on the function specified in our core UI ops for us to finish configuring libpurple
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   213
	if (!purple_core_init("Adium")) {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   214
		NSLog(@"*** FATAL ***: Failed to initialize purple core");
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   215
		AILog(@"*** FATAL ***: Failed to initialize purple core");
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   216
	}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   217
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   218
	//Libpurple's async DNS lookup tends to create zombies.
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   219
	{
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   220
		struct sigaction act;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   221
		
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   222
		act.sa_handler = ZombieKiller_Signal;		
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   223
		//Send for terminated but not stopped children
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   224
		act.sa_flags = SA_NOCLDWAIT;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   225
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   226
		sigaction(SIGCHLD, &act, NULL);
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   227
	}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   228
	
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   229
	//Observe for network changes to tell libpurple about it
1109
092c44a2cfbb Having a separate notification center for Adium leads to the possibility of accidentally using the wrong one, which has tripped me up on more than one occasion. This switches us over to using the default center.
David Smith
parents: 838
diff changeset
   230
	[[NSNotificationCenter defaultCenter] addObserver:self
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   231
								   selector:@selector(networkDidChange:)
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   232
									   name:AINetworkDidChangeNotification
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   233
									 object:nil];
3161
c959997fcffb Delay list object notifications as libpurple initializes; it can be expensive in terms of adding contacts from the permit and deny lists. Also, include a delayListObjectNotificationsUntilInactivity call as a few behaviors occur on the next runloop
Evan Schoenberg
parents: 3083
diff changeset
   234
3200
f04d1fb6ef86 Enable debug logging at runtime as appropriate rather than at compile times. Refs #14465 (where it was noted that a user's debug log didn't contain any libpurple information).
Evan Schoenberg
parents: 3197
diff changeset
   235
	/* Be sure to enable debug logging if it is turned on after launch */
f04d1fb6ef86 Enable debug logging at runtime as appropriate rather than at compile times. Refs #14465 (where it was noted that a user's debug log didn't contain any libpurple information).
Evan Schoenberg
parents: 3197
diff changeset
   236
	[[NSNotificationCenter defaultCenter] addObserver:self
f04d1fb6ef86 Enable debug logging at runtime as appropriate rather than at compile times. Refs #14465 (where it was noted that a user's debug log didn't contain any libpurple information).
Evan Schoenberg
parents: 3197
diff changeset
   237
											 selector:@selector(debugLoggingIsEnabledDidChange:)
f04d1fb6ef86 Enable debug logging at runtime as appropriate rather than at compile times. Refs #14465 (where it was noted that a user's debug log didn't contain any libpurple information).
Evan Schoenberg
parents: 3197
diff changeset
   238
												 name:AIDebugLoggingEnabledNotification
f04d1fb6ef86 Enable debug logging at runtime as appropriate rather than at compile times. Refs #14465 (where it was noted that a user's debug log didn't contain any libpurple information).
Evan Schoenberg
parents: 3197
diff changeset
   239
											   object:nil];
f04d1fb6ef86 Enable debug logging at runtime as appropriate rather than at compile times. Refs #14465 (where it was noted that a user's debug log didn't contain any libpurple information).
Evan Schoenberg
parents: 3197
diff changeset
   240
f04d1fb6ef86 Enable debug logging at runtime as appropriate rather than at compile times. Refs #14465 (where it was noted that a user's debug log didn't contain any libpurple information).
Evan Schoenberg
parents: 3197
diff changeset
   241
	
3161
c959997fcffb Delay list object notifications as libpurple initializes; it can be expensive in terms of adding contacts from the permit and deny lists. Also, include a delayListObjectNotificationsUntilInactivity call as a few behaviors occur on the next runloop
Evan Schoenberg
parents: 3083
diff changeset
   242
	/* For any behaviors which occur on the next run loop, provide a buffer time of continued expectation of 
c959997fcffb Delay list object notifications as libpurple initializes; it can be expensive in terms of adding contacts from the permit and deny lists. Also, include a delayListObjectNotificationsUntilInactivity call as a few behaviors occur on the next runloop
Evan Schoenberg
parents: 3083
diff changeset
   243
	 * heavy activity.
c959997fcffb Delay list object notifications as libpurple initializes; it can be expensive in terms of adding contacts from the permit and deny lists. Also, include a delayListObjectNotificationsUntilInactivity call as a few behaviors occur on the next runloop
Evan Schoenberg
parents: 3083
diff changeset
   244
	 */
c959997fcffb Delay list object notifications as libpurple initializes; it can be expensive in terms of adding contacts from the permit and deny lists. Also, include a delayListObjectNotificationsUntilInactivity call as a few behaviors occur on the next runloop
Evan Schoenberg
parents: 3083
diff changeset
   245
	[[AIContactObserverManager sharedManager] delayListObjectNotificationsUntilInactivity];
c959997fcffb Delay list object notifications as libpurple initializes; it can be expensive in terms of adding contacts from the permit and deny lists. Also, include a delayListObjectNotificationsUntilInactivity call as a few behaviors occur on the next runloop
Evan Schoenberg
parents: 3083
diff changeset
   246
	
c959997fcffb Delay list object notifications as libpurple initializes; it can be expensive in terms of adding contacts from the permit and deny lists. Also, include a delayListObjectNotificationsUntilInactivity call as a few behaviors occur on the next runloop
Evan Schoenberg
parents: 3083
diff changeset
   247
	[[AIContactObserverManager sharedManager] endListObjectNotificationsDelay];
c959997fcffb Delay list object notifications as libpurple initializes; it can be expensive in terms of adding contacts from the permit and deny lists. Also, include a delayListObjectNotificationsUntilInactivity call as a few behaviors occur on the next runloop
Evan Schoenberg
parents: 3083
diff changeset
   248
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   249
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   250
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   251
#pragma mark Lookup functions
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   252
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   253
NSString* serviceClassForPurpleProtocolID(const char *protocolID)
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   254
{
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   255
	NSString	*serviceClass = nil;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   256
	if (protocolID) {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   257
		if (!strcmp(protocolID, "prpl-oscar"))
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   258
			serviceClass = @"AIM-compatible";
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   259
		else if (!strcmp(protocolID, "prpl-gg"))
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   260
			serviceClass = @"Gadu-Gadu";
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   261
		else if (!strcmp(protocolID, "prpl-jabber"))
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   262
			serviceClass = @"Jabber";
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   263
		else if (!strcmp(protocolID, "prpl-meanwhile"))
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   264
			serviceClass = @"Sametime";
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   265
		else if (!strcmp(protocolID, "prpl-msn"))
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   266
			serviceClass = @"MSN";
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   267
		else if (!strcmp(protocolID, "prpl-novell"))
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   268
			serviceClass = @"GroupWise";
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   269
		else if (!strcmp(protocolID, "prpl-yahoo"))
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   270
			serviceClass = @"Yahoo!";
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   271
		else if (!strcmp(protocolID, "prpl-zephyr"))
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   272
			serviceClass = @"Zephyr";
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   273
	}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   274
	
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   275
	return serviceClass;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   276
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   277
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   278
/*
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   279
 * Finds an instance of CBPurpleAccount for a pointer to a PurpleAccount struct.
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   280
 */
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   281
CBPurpleAccount* accountLookup(PurpleAccount *acct)
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   282
{
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   283
	CBPurpleAccount *adiumPurpleAccount = (acct ? (CBPurpleAccount *)acct->ui_data : nil);
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   284
	/* If the account doesn't have its ui_data associated yet (we haven't tried to connect) but we want this
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   285
	 * lookup data, we have to do some manual parsing.  This is used for example from the OTR preferences.
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   286
	 */
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   287
	if (!adiumPurpleAccount && acct) {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   288
		const char	*protocolID = acct->protocol_id;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   289
		NSString	*serviceClass = serviceClassForPurpleProtocolID(protocolID);
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   290
166
a43b4310ef2a Updated most of our enumerations to fast enumerations, and did some paramaterization.
Evan Schoenberg
parents: 100
diff changeset
   291
		for (adiumPurpleAccount in adium.accountController.accounts) {
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   292
			if ([adiumPurpleAccount isKindOfClass:[CBPurpleAccount class]] &&
715
13cd227e6284 Propertyize a bunch of stuff, and remove some API on AIListObject that was just a passthrough to AIService
David Smith
parents: 709
diff changeset
   293
			   [adiumPurpleAccount.service.serviceClass isEqualToString:serviceClass] &&
166
a43b4310ef2a Updated most of our enumerations to fast enumerations, and did some paramaterization.
Evan Schoenberg
parents: 100
diff changeset
   294
			   [adiumPurpleAccount.UID caseInsensitiveCompare:[NSString stringWithUTF8String:acct->username]] == NSOrderedSame) {
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   295
				break;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   296
			}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   297
		}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   298
	}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   299
    return adiumPurpleAccount;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   300
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   301
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   302
PurpleAccount* accountLookupFromAdiumAccount(CBPurpleAccount *adiumAccount)
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   303
{
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   304
	return [adiumAccount purpleAccount];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   305
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   306
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   307
AIListContact* contactLookupFromBuddy(PurpleBuddy *buddy)
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   308
{
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   309
	//Get the node's ui_data
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   310
	AIListContact *theContact = (buddy ? (AIListContact *)buddy->node.ui_data : nil);
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   311
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   312
	//If the node does not have ui_data yet, we need to create a contact and associate it
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   313
	if (!theContact && buddy) {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   314
		NSString	*UID;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   315
	
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   316
		UID = [NSString stringWithUTF8String:purple_normalize(purple_buddy_get_account(buddy), purple_buddy_get_name(buddy))];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   317
		
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   318
		theContact = [accountLookup(purple_buddy_get_account(buddy)) contactWithUID:UID];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   319
		
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   320
		//Associate the handle with ui_data and the buddy with our statusDictionary
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   321
		buddy->node.ui_data = [theContact retain];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   322
		
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   323
		//This is the first time the contact has been accessed from the buddy; reset the icon cache for it
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   324
		[AIUserIcons flushCacheForObject:theContact];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   325
	}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   326
	
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   327
	return theContact;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   328
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   329
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   330
AIListContact* contactLookupFromIMConv(PurpleConversation *conv)
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   331
{
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   332
	return nil;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   333
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   334
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   335
AIChat* groupChatLookupFromConv(PurpleConversation *conv)
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   336
{
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   337
	AIChat *chat;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   338
	
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   339
	chat = (AIChat *)conv->ui_data;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   340
	if (!chat) {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   341
		NSString *name = [NSString stringWithUTF8String:purple_conversation_get_name(conv)];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   342
		
1158
bb42b16ad8f5 Sketch out a mechanism for chats not started directly from our UI (/join, invite accept) to figure out what their chat creation dicts should be. At the moment this only works for one key on irc channels, but it should be expandable to other protocols and keys. The duplication of code here is ugly, but I am unclear on how to improve it. Refs #11789
David Smith
parents: 1109
diff changeset
   343
		CBPurpleAccount *account = accountLookup(purple_conversation_get_account(conv));
3610
93c8292bc1c8 Apply the same fix as a00b7964253b, but for group chats, again resolving a double-retain
Evan Schoenberg
parents: 3608
diff changeset
   344
        
93c8292bc1c8 Apply the same fix as a00b7964253b, but for group chats, again resolving a double-retain
Evan Schoenberg
parents: 3608
diff changeset
   345
        /* 
93c8292bc1c8 Apply the same fix as a00b7964253b, but for group chats, again resolving a double-retain
Evan Schoenberg
parents: 3608
diff changeset
   346
         * Need to start a new chat, associating with the PurpleConversation.
93c8292bc1c8 Apply the same fix as a00b7964253b, but for group chats, again resolving a double-retain
Evan Schoenberg
parents: 3608
diff changeset
   347
         *
93c8292bc1c8 Apply the same fix as a00b7964253b, but for group chats, again resolving a double-retain
Evan Schoenberg
parents: 3608
diff changeset
   348
         * This may call back through to us recursively, via:
93c8292bc1c8 Apply the same fix as a00b7964253b, but for group chats, again resolving a double-retain
Evan Schoenberg
parents: 3608
diff changeset
   349
         *   -[CBPurpleAccount chatWithContact:identifier:]
93c8292bc1c8 Apply the same fix as a00b7964253b, but for group chats, again resolving a double-retain
Evan Schoenberg
parents: 3608
diff changeset
   350
         *   -[AIChatController chatWithContact:]
93c8292bc1c8 Apply the same fix as a00b7964253b, but for group chats, again resolving a double-retain
Evan Schoenberg
parents: 3608
diff changeset
   351
         *   -[CBPurpleAccount openChat:]
93c8292bc1c8 Apply the same fix as a00b7964253b, but for group chats, again resolving a double-retain
Evan Schoenberg
parents: 3608
diff changeset
   352
         *   -[SLPurpleCocoaAdaper openChat:onAccount:]
93c8292bc1c8 Apply the same fix as a00b7964253b, but for group chats, again resolving a double-retain
Evan Schoenberg
parents: 3608
diff changeset
   353
         *   convLookupFromChat()
93c8292bc1c8 Apply the same fix as a00b7964253b, but for group chats, again resolving a double-retain
Evan Schoenberg
parents: 3608
diff changeset
   354
         *   groupChatLookupFromConv()
93c8292bc1c8 Apply the same fix as a00b7964253b, but for group chats, again resolving a double-retain
Evan Schoenberg
parents: 3608
diff changeset
   355
         *
93c8292bc1c8 Apply the same fix as a00b7964253b, but for group chats, again resolving a double-retain
Evan Schoenberg
parents: 3608
diff changeset
   356
         * That's fine, as we'll get the same lookups the second time through; we just need to be cautious.
93c8292bc1c8 Apply the same fix as a00b7964253b, but for group chats, again resolving a double-retain
Evan Schoenberg
parents: 3608
diff changeset
   357
         */
1158
bb42b16ad8f5 Sketch out a mechanism for chats not started directly from our UI (/join, invite accept) to figure out what their chat creation dicts should be. At the moment this only works for one key on irc channels, but it should be expandable to other protocols and keys. The duplication of code here is ugly, but I am unclear on how to improve it. Refs #11789
David Smith
parents: 1109
diff changeset
   358
		chat = [account chatWithName:name identifier:[NSValue valueWithPointer:conv]];
1912
43f4b2e065e1 Don't set the chatCreationDictionary when joining a chat which already has the dictionary set. For jabber chats, we were always setting them to nil, and probably other things too.
Zachary West <zacw@adiumx.com>
parents: 1770
diff changeset
   359
		if (!chat.chatCreationDictionary) {
43f4b2e065e1 Don't set the chatCreationDictionary when joining a chat which already has the dictionary set. For jabber chats, we were always setting them to nil, and probably other things too.
Zachary West <zacw@adiumx.com>
parents: 1770
diff changeset
   360
			// If we don't have a chat creation dictionary (i.e., we didn't initiate the join), create one.
43f4b2e065e1 Don't set the chatCreationDictionary when joining a chat which already has the dictionary set. For jabber chats, we were always setting them to nil, and probably other things too.
Zachary West <zacw@adiumx.com>
parents: 1770
diff changeset
   361
			chat.chatCreationDictionary = [account extractChatCreationDictionaryFromConversation: conv];
43f4b2e065e1 Don't set the chatCreationDictionary when joining a chat which already has the dictionary set. For jabber chats, we were always setting them to nil, and probably other things too.
Zachary West <zacw@adiumx.com>
parents: 1770
diff changeset
   362
		}
3610
93c8292bc1c8 Apply the same fix as a00b7964253b, but for group chats, again resolving a double-retain
Evan Schoenberg
parents: 3608
diff changeset
   363
        if (conv->ui_data != chat) {
93c8292bc1c8 Apply the same fix as a00b7964253b, but for group chats, again resolving a double-retain
Evan Schoenberg
parents: 3608
diff changeset
   364
            [(AIChat *)(conv->ui_data) release];
93c8292bc1c8 Apply the same fix as a00b7964253b, but for group chats, again resolving a double-retain
Evan Schoenberg
parents: 3608
diff changeset
   365
            conv->ui_data = [chat retain];
93c8292bc1c8 Apply the same fix as a00b7964253b, but for group chats, again resolving a double-retain
Evan Schoenberg
parents: 3608
diff changeset
   366
        }
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   367
		AILog(@"group chat lookup assigned %@ to %p (%s)",chat,conv, purple_conversation_get_name(conv));
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   368
	}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   369
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   370
	return chat;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   371
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   372
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   373
AIChat* existingChatLookupFromConv(PurpleConversation *conv)
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   374
{
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   375
	return (conv ? conv->ui_data : nil);
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   376
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   377
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   378
AIChat* chatLookupFromConv(PurpleConversation *conv)
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   379
{
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   380
	switch(purple_conversation_get_type(conv)) {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   381
		case PURPLE_CONV_TYPE_CHAT:
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   382
			return groupChatLookupFromConv(conv);
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   383
			break;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   384
		case PURPLE_CONV_TYPE_IM:
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   385
			return imChatLookupFromConv(conv);
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   386
			break;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   387
		default:
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   388
			return existingChatLookupFromConv(conv);
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   389
			break;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   390
	}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   391
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   392
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   393
AIChat* imChatLookupFromConv(PurpleConversation *conv)
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   394
{
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   395
	AIChat			*chat;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   396
	
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   397
	chat = (AIChat *)conv->ui_data;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   398
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   399
	if (!chat) {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   400
		//No chat is associated with the IM conversation
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   401
		AIListContact   *sourceContact;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   402
		PurpleBuddy		*buddy;
3608
c5435740e49b Fix an AIChat leak caused by a double-retain via recursion within imChatLookupFromConv()
Evan Schoenberg
parents: 3516
diff changeset
   403
		PurpleAccount	*account;
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   404
		
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   405
		account = purple_conversation_get_account(conv);
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   406
//		AILog(@"%x purple_conversation_get_name(conv) %s; normalizes to %s",account,purple_conversation_get_name(conv),purple_normalize(account,purple_conversation_get_name(conv)));
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   407
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   408
		//First, find the PurpleBuddy with whom we are conversing
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   409
		buddy = purple_find_buddy(account, purple_conversation_get_name(conv));
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   410
		if (!buddy) {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   411
			//No purple_buddy corresponding to the purple_conversation_get_name(conv) is on our list, so create one
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   412
			buddy = purple_buddy_new(account, purple_normalize(account, purple_conversation_get_name(conv)), NULL);	//create a PurpleBuddy
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   413
		}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   414
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   415
		NSCAssert(buddy != nil, @"buddy was nil");
3608
c5435740e49b Fix an AIChat leak caused by a double-retain via recursion within imChatLookupFromConv()
Evan Schoenberg
parents: 3516
diff changeset
   416
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   417
		sourceContact = contactLookupFromBuddy(buddy);
3608
c5435740e49b Fix an AIChat leak caused by a double-retain via recursion within imChatLookupFromConv()
Evan Schoenberg
parents: 3516
diff changeset
   418
		/* 
c5435740e49b Fix an AIChat leak caused by a double-retain via recursion within imChatLookupFromConv()
Evan Schoenberg
parents: 3516
diff changeset
   419
         * Need to start a new chat, associating with the PurpleConversation.
c5435740e49b Fix an AIChat leak caused by a double-retain via recursion within imChatLookupFromConv()
Evan Schoenberg
parents: 3516
diff changeset
   420
         *
c5435740e49b Fix an AIChat leak caused by a double-retain via recursion within imChatLookupFromConv()
Evan Schoenberg
parents: 3516
diff changeset
   421
         * This may call back through to us recursively, via:
c5435740e49b Fix an AIChat leak caused by a double-retain via recursion within imChatLookupFromConv()
Evan Schoenberg
parents: 3516
diff changeset
   422
         *   -[CBPurpleAccount chatWithContact:identifier:]
c5435740e49b Fix an AIChat leak caused by a double-retain via recursion within imChatLookupFromConv()
Evan Schoenberg
parents: 3516
diff changeset
   423
         *   -[AIChatController chatWithContact:]
c5435740e49b Fix an AIChat leak caused by a double-retain via recursion within imChatLookupFromConv()
Evan Schoenberg
parents: 3516
diff changeset
   424
         *   -[CBPurpleAccount openChat:]
c5435740e49b Fix an AIChat leak caused by a double-retain via recursion within imChatLookupFromConv()
Evan Schoenberg
parents: 3516
diff changeset
   425
         *   -[SLPurpleCocoaAdaper openChat:onAccount:]
c5435740e49b Fix an AIChat leak caused by a double-retain via recursion within imChatLookupFromConv()
Evan Schoenberg
parents: 3516
diff changeset
   426
         *   convLookupFromChat()
c5435740e49b Fix an AIChat leak caused by a double-retain via recursion within imChatLookupFromConv()
Evan Schoenberg
parents: 3516
diff changeset
   427
         *   imChatLookupFromConv()
c5435740e49b Fix an AIChat leak caused by a double-retain via recursion within imChatLookupFromConv()
Evan Schoenberg
parents: 3516
diff changeset
   428
         *
c5435740e49b Fix an AIChat leak caused by a double-retain via recursion within imChatLookupFromConv()
Evan Schoenberg
parents: 3516
diff changeset
   429
         * That's fine, as we'll get the same lookups the second time through; we just need to be cautious.
c5435740e49b Fix an AIChat leak caused by a double-retain via recursion within imChatLookupFromConv()
Evan Schoenberg
parents: 3516
diff changeset
   430
         */
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   431
		chat = [accountLookup(account) chatWithContact:sourceContact identifier:[NSValue valueWithPointer:conv]];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   432
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   433
		if (!chat) {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   434
			NSString	*errorString;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   435
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   436
			errorString = [NSString stringWithFormat:@"conv %x: Got nil chat in lookup for sourceContact %@ (%x ; \"%s\" ; \"%s\") on adiumAccount %@ (%x ; \"%s\")",
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   437
				conv,
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   438
				sourceContact,
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   439
				buddy,
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   440
				(buddy ? purple_buddy_get_name(buddy) : ""),
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   441
				((buddy && purple_buddy_get_account(buddy) && purple_buddy_get_name(buddy)) ? purple_normalize(purple_buddy_get_account(buddy), purple_buddy_get_name(buddy)) : ""),
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   442
				accountLookup(account),
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   443
				account,
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   444
				(account ? purple_account_get_username(account) : "")];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   445
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   446
			NSCAssert(chat != nil, errorString);
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   447
		}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   448
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   449
		//Associate the PurpleConversation with the AIChat
3608
c5435740e49b Fix an AIChat leak caused by a double-retain via recursion within imChatLookupFromConv()
Evan Schoenberg
parents: 3516
diff changeset
   450
        if (conv->ui_data != chat) {
c5435740e49b Fix an AIChat leak caused by a double-retain via recursion within imChatLookupFromConv()
Evan Schoenberg
parents: 3516
diff changeset
   451
            [(AIChat *)(conv->ui_data) release];
c5435740e49b Fix an AIChat leak caused by a double-retain via recursion within imChatLookupFromConv()
Evan Schoenberg
parents: 3516
diff changeset
   452
            conv->ui_data = [chat retain];
c5435740e49b Fix an AIChat leak caused by a double-retain via recursion within imChatLookupFromConv()
Evan Schoenberg
parents: 3516
diff changeset
   453
        }
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   454
	}
3608
c5435740e49b Fix an AIChat leak caused by a double-retain via recursion within imChatLookupFromConv()
Evan Schoenberg
parents: 3516
diff changeset
   455
    
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   456
	return chat;	
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   457
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   458
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   459
PurpleConversation* convLookupFromChat(AIChat *chat, id adiumAccount)
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   460
{
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   461
	PurpleConversation	*conv = [[chat identifier] pointerValue];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   462
	PurpleAccount		*account = accountLookupFromAdiumAccount(adiumAccount);
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   463
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   464
	if (!conv && adiumAccount && purple_account_get_connection(account)) {
426
837e43c8d35d I was hungry and didn't feel like working on hard stuff, so I did a bunch of propertyizing instead.
David Smith
parents: 166
diff changeset
   465
		AIListObject *listObject = chat.listObject;
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   466
		
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   467
		//If we have a listObject, we are dealing with a one-on-one chat, so proceed accordingly
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   468
		if (listObject) {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   469
			char *destination;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   470
			
721
7a01f7df42eb Propertyize + build fix
David Smith
parents: 715
diff changeset
   471
			destination = g_strdup(purple_normalize(account, [listObject.UID UTF8String]));
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   472
			
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   473
			conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, account, destination);
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   474
			
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   475
			//associate the AIChat with the purple conv
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   476
			if (conv) imChatLookupFromConv(conv);
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   477
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   478
			g_free(destination);
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   479
			
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   480
		} else {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   481
			//Otherwise, we have a multiuser chat.
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   482
			
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   483
			//All multiuser chats should have a non-nil name.
721
7a01f7df42eb Propertyize + build fix
David Smith
parents: 715
diff changeset
   484
			NSString	*chatName = chat.name;
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   485
			if (chatName) {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   486
				const char *name = [chatName UTF8String];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   487
				
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   488
				/*
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   489
				 Look for an existing purpleChat.  If we find one, our job is complete.
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   490
				 
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   491
				 We will never find one if we are joining a chat on our own (via the Join Chat dialogue).
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   492
				 
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   493
				 We should never get to this point if we were invited to a chat, as groupChatLookupFromConv(),
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   494
				 which was called when we accepted the invitation and got the chat information from Purple,
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   495
				 will have associated the PurpleConversation with the chat and we would have stopped after
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   496
				 [[chat identifier] pointerValue] above.
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   497
				 
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   498
				 However, there's no reason not to check just in case.
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   499
				 */
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   500
				PurpleChat *purpleChat = purple_blist_find_chat(account, name);
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   501
				if (!purpleChat) {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   502
					
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   503
					/*
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   504
					 If we don't have a PurpleChat with this name on this account, we need to create one.
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   505
					 Our chat, which should have been created via the Adium Join Chat API, should have
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   506
					 a ChatCreationInfo property with the information we need to ask Purple to
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   507
					 perform the join.
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   508
					 */
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   509
					NSDictionary	*chatCreationInfo = [chat valueForProperty:@"ChatCreationInfo"];
426
837e43c8d35d I was hungry and didn't feel like working on hard stuff, so I did a bunch of propertyizing instead.
David Smith
parents: 166
diff changeset
   510
					chatCreationInfo = [(CBPurpleAccount *)chat.account willJoinChatUsingDictionary:chatCreationInfo];
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   511
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   512
					if (!chatCreationInfo) {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   513
						AILog(@"*** No chat creation info for %@ on %@",chat,adiumAccount);
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   514
						return NULL;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   515
					}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   516
					
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   517
					AILog(@"Creating a chat with name %s (Creation info: %@).", name, chatCreationInfo);
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   518
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   519
					GHashTable				*components;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   520
					
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   521
					//Prpl Info
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   522
					PurpleConnection		*gc = purple_account_get_connection(account);
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   523
					GList					*list, *tmp;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   524
					struct proto_chat_entry *pce;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   525
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   526
					g_return_val_if_fail(gc != NULL, NULL);
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   527
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   528
					//Create a hash table
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   529
					//The hash table should contain char* objects created via a g_strdup method
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   530
					components = g_hash_table_new_full(g_str_hash, g_str_equal,
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   531
													   g_free, g_free);
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   532
					
695
ba35b01faac9 More fiddling with compiler settings, and fixing a few warnings from enabling 'warn about locals shadowing things', although I am not actually turning that on because it made every 'index' variable in Adium warn about shadowing something in string.h
David Smith
parents: 677
diff changeset
   533
					for (NSString *identifier in chatCreationInfo) {
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   534
						id		value = [chatCreationInfo objectForKey:identifier];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   535
						char	*valueUTF8String = NULL;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   536
						
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   537
						if ([value isKindOfClass:[NSNumber class]]) {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   538
							valueUTF8String = g_strdup_printf("%d",[value intValue]);
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   539
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   540
						} else if ([value isKindOfClass:[NSString class]]) {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   541
							valueUTF8String = g_strdup([value UTF8String]);
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   542
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   543
						} else {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   544
							AILog(@"Invalid value %@ for identifier %@",value,identifier);
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   545
						}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   546
						
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   547
						//Store our chatCreationInfo-supplied value in the compnents hash table
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   548
						if (valueUTF8String) {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   549
							g_hash_table_replace(components,
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   550
												 g_strdup([identifier UTF8String]),
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   551
												 valueUTF8String);
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   552
						}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   553
					}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   554
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   555
					//In debug mode, verify we didn't miss any required values
3200
f04d1fb6ef86 Enable debug logging at runtime as appropriate rather than at compile times. Refs #14465 (where it was noted that a user's debug log didn't contain any libpurple information).
Evan Schoenberg
parents: 3197
diff changeset
   556
					if (AIDebugLoggingIsEnabled()) {
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   557
						/* Get the chat_info for our desired account.  This will be a GList of proto_chat_entry
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   558
						 * objects, each of which has a label and identifier.  Each may also have is_int, with a minimum
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   559
						 * and a maximum integer value.
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   560
						 */
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   561
						if ((PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl))->chat_info)
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   562
						{
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   563
							list = (PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl))->chat_info(gc);
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   564
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   565
							//Look at each proto_chat_entry in the list to verify we have it in chatCreationInfo
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   566
							for (tmp = list; tmp; tmp = tmp->next)
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   567
							{
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   568
								pce = tmp->data;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   569
								char	*identifier = g_strdup(pce->identifier);
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   570
								
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   571
								NSString	*value = [chatCreationInfo objectForKey:[NSString stringWithUTF8String:identifier]];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   572
								if (!value) {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   573
									AILog(@"Danger, Will Robinson! %s is in the proto_info but can't be found in %@",identifier,chatCreationInfo);
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   574
								}
1640
d3e462b42a7c Plug a leak in convLookupFromChat.
Zachary West <zacw@adiumx.com>
parents: 1622
diff changeset
   575
								
d3e462b42a7c Plug a leak in convLookupFromChat.
Zachary West <zacw@adiumx.com>
parents: 1622
diff changeset
   576
								g_free(identifier);
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   577
							}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   578
						}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   579
					}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   580
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   581
					/* Join the chat serverside - the GHashTable components, coupled with the originating PurpleConnection,
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   582
					 * now contains all the information the prpl will need to process our request.
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   583
					 */
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   584
					AILog(@"In the event of an emergency, your GHashTable may be used as a flotation device...");
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   585
					serv_join_chat(gc, components);
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   586
					g_hash_table_unref(components);
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   587
				}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   588
			}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   589
		}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   590
	}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   591
	
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   592
	return conv;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   593
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   594
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   595
PurpleConversation* existingConvLookupFromChat(AIChat *chat)
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   596
{
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   597
	return (PurpleConversation *)[[chat identifier] pointerValue];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   598
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   599
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   600
void* adium_purple_get_handle(void)
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   601
{
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   602
	static int adium_purple_handle;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   603
	
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   604
	return &adium_purple_handle;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   605
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   606
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   607
#pragma mark Images
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   608
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   609
static NSString *_messageImageCachePathWithoutExtension(int imageID, AIAccount* adiumAccount)
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   610
{
838
0f6dc3d1afd7 More dot syntax. Hooray regexes
David Smith
parents: 774
diff changeset
   611
    NSString    *messageImageCacheFilename = [NSString stringWithFormat:@"TEMP-Image_%@_%i", adiumAccount.internalObjectID, imageID];
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   612
    return [[adium cachesPath] stringByAppendingPathComponent:messageImageCacheFilename];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   613
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   614
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   615
NSString *processPurpleImages(NSString* inString, AIAccount* adiumAccount)
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   616
{
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   617
	NSScanner			*scanner;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   618
    NSString			*chunkString = nil;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   619
    NSMutableString		*newString;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   620
	NSString			*targetString = @"<IMG ID=";
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   621
	NSCharacterSet		*quoteApostropheCharacterSet = [NSCharacterSet characterSetWithCharactersInString:@"\"\'"];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   622
    int imageID;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   623
	
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   624
	if ([inString rangeOfString:targetString options:NSCaseInsensitiveSearch].location == NSNotFound) {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   625
		return inString;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   626
	}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   627
	
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   628
    //set up
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   629
	newString = [[NSMutableString alloc] init];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   630
	
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   631
    scanner = [NSScanner scannerWithString:inString];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   632
    [scanner setCharactersToBeSkipped:[NSCharacterSet characterSetWithCharactersInString:@""]];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   633
	
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   634
	//A purple image tag takes the form <IMG ID='12'></IMG> where 12 is the reference for use in PurpleStoredImage* purple_imgstore_get(int)
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   635
	
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   636
	//Parse the incoming HTML
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   637
    while (![scanner isAtEnd]) {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   638
		//Find the beginning of a purple IMG ID tag
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   639
		if ([scanner scanUpToString:targetString intoString:&chunkString]) {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   640
			[newString appendString:chunkString];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   641
		}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   642
		
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   643
		if ([scanner scanString:targetString intoString:&chunkString]) {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   644
			//Skip past a quote or apostrophe
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   645
			[scanner scanCharactersFromSet:quoteApostropheCharacterSet intoString:NULL];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   646
			
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   647
			//Get the image ID from the tag
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   648
			[scanner scanInt:&imageID];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   649
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   650
			//Skip past a quote or apostrophe
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   651
			[scanner scanCharactersFromSet:quoteApostropheCharacterSet intoString:NULL];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   652
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   653
			//Scan past a >
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   654
			[scanner scanString:@">" intoString:nil];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   655
			
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   656
			//Get the image, then write it out as a png
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   657
			PurpleStoredImage		*purpleImage = purple_imgstore_find_by_id(imageID);
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   658
			if (purpleImage) {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   659
				NSString		*filename = (purple_imgstore_get_filename(purpleImage) ?
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   660
											 [NSString stringWithUTF8String:purple_imgstore_get_filename(purpleImage)] :
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   661
											 @"Image");
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   662
				NSString		*imagePath = _messageImageCachePathWithoutExtension(imageID, adiumAccount);
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   663
				
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   664
				//First make an NSImage, then request a TIFFRepresentation to avoid an obscure bug in the PNG writing routines
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   665
				//Exception: PNG writer requires compacted components (bits/component * components/pixel = bits/pixel)
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   666
				NSData *data = [NSData dataWithBytes:purple_imgstore_get_data(purpleImage)
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   667
											  length:purple_imgstore_get_size(purpleImage)];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   668
				
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   669
				NSString *extension = [NSImage extensionForBitmapImageFileType:[NSImage fileTypeOfData:data]];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   670
				if (!extension) {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   671
					//We don't know what it is; try to make a png out of it
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   672
					NSImage				*image = [[NSImage alloc] initWithData:data];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   673
					NSData				*imageTIFFData = [image TIFFRepresentation];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   674
					NSBitmapImageRep	*bitmapRep = [NSBitmapImageRep imageRepWithData:imageTIFFData];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   675
					
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   676
					data = [bitmapRep representationUsingType:NSPNGFileType properties:nil];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   677
					extension = @"png";
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   678
					[image release];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   679
				}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   680
				
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   681
				filename = [filename stringByAppendingPathExtension:extension];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   682
				imagePath = [imagePath stringByAppendingPathExtension:extension];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   683
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   684
				//If writing the file is successful, write an <IMG SRC="filepath"> tag to our string; the 'scaledToFitImage' class lets us apply CSS to directIM images only
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   685
				if ([data writeToFile:imagePath atomically:YES]) {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   686
					[newString appendString:[NSString stringWithFormat:@"<IMG CLASS=\"scaledToFitImage\" SRC=\"%@\" ALT=\"%@\">",
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   687
						imagePath, filename]];	
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   688
				}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   689
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   690
			} else {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   691
				//If we didn't get a purpleImage, just leave the tag for now.. maybe it was important?
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   692
				[newString appendFormat:@"<IMG ID=\"%i\">",chunkString];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   693
			}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   694
		}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   695
	}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   696
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   697
	return ([newString autorelease]);
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   698
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   699
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   700
#pragma mark Notify
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   701
// Notify ----------------------------------------------------------------------------------------------------------
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   702
// We handle the notify messages within SLPurpleCocoaAdapter so we can use our localized string macro
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   703
- (void *)handleNotifyMessageOfType:(PurpleNotifyType)type withTitle:(const char *)title primary:(const char *)primary secondary:(const char *)secondary;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   704
{
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   705
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   706
    NSString *primaryString = [NSString stringWithUTF8String:primary];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   707
	NSString *secondaryString = secondary ? [NSString stringWithUTF8String:secondary] : nil;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   708
	
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   709
	NSString *titleString;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   710
	if (title) {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   711
		titleString = [NSString stringWithFormat:AILocalizedString(@"Adium Notice: %@",nil),[NSString stringWithUTF8String:title]];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   712
	} else {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   713
		titleString = AILocalizedString(@"Adium : Notice", nil);
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   714
	}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   715
	
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   716
	NSString *errorMessage = nil;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   717
	NSString *description = nil;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   718
	
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   719
	if (primary && strcmp(primary, _("Already there")) == 0) 
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   720
		return NULL;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   721
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   722
	//Suppress notification warnings we have no interest in seeing
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   723
	if (secondaryString) {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   724
		if ((strcmp(secondary, _("Not supported by host")) == 0) || /* OSCAR */
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   725
			(strcmp(secondary, _("Not logged in")) == 0) || /* OSCAR */
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   726
			(strcmp(secondary, _("Your buddy list was downloaded from the server.")) == 0) || /* Gadu-gadu */
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   727
			(strcmp(secondary, _("Your buddy list was stored on the server.")) == 0) /* Gadu-gadu */) {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   728
			return NULL;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   729
		}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   730
		
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   731
		if ([secondaryString isEqualToString:
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   732
			 [NSString stringWithFormat:[NSString stringWithUTF8String:_("Could not add the buddy %s for an unknown reason.")], "1"]]) {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   733
			/* Rather random error displayed by OSCAR (since forever, as of libpurple 2.4.0) for some clients while connecting */
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   734
			return NULL;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   735
		}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   736
		
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   737
		if ([secondaryString rangeOfString:@"Your contact is using Windows Live"].location != NSNotFound) {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   738
			 /* Yahoo without MSN support - English string from the server */
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   739
			return NULL;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   740
		}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   741
3197
700131f4c0b6 Fix a localization problem in which these substituted error messages wouldn't be shown in their localized form
Evan Schoenberg
parents: 3161
diff changeset
   742
	} 
700131f4c0b6 Fix a localization problem in which these substituted error messages wouldn't be shown in their localized form
Evan Schoenberg
parents: 3161
diff changeset
   743
	
700131f4c0b6 Fix a localization problem in which these substituted error messages wouldn't be shown in their localized form
Evan Schoenberg
parents: 3161
diff changeset
   744
	if ([primaryString rangeOfString: @"did not get sent"].location != NSNotFound) {
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   745
		//Oscar send error
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   746
		//This may not ever occur as of libpurple 2.4.0; I can't find the phrase 'did not get sent' in any of the code. -evands
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   747
		NSString *targetUserName = [[[[primaryString componentsSeparatedByString:@" message to "] objectAtIndex:1] componentsSeparatedByString:@" did not get "] objectAtIndex:0];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   748
		
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   749
		errorMessage = [NSString stringWithFormat:AILocalizedString(@"Your message to %@ did not get sent",nil),targetUserName];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   750
		
3197
700131f4c0b6 Fix a localization problem in which these substituted error messages wouldn't be shown in their localized form
Evan Schoenberg
parents: 3161
diff changeset
   751
		if (secondaryString) {
700131f4c0b6 Fix a localization problem in which these substituted error messages wouldn't be shown in their localized form
Evan Schoenberg
parents: 3161
diff changeset
   752
			if ([secondaryString rangeOfString:[NSString stringWithUTF8String:_("Rate")]].location != NSNotFound) {
700131f4c0b6 Fix a localization problem in which these substituted error messages wouldn't be shown in their localized form
Evan Schoenberg
parents: 3161
diff changeset
   753
				description = AILocalizedString(@"You are sending messages too quickly; wait a moment and try again.",nil);
700131f4c0b6 Fix a localization problem in which these substituted error messages wouldn't be shown in their localized form
Evan Schoenberg
parents: 3161
diff changeset
   754
			} else if ([secondaryString rangeOfString:[NSString stringWithUTF8String:_("Service unavailable")]].location != NSNotFound ||
700131f4c0b6 Fix a localization problem in which these substituted error messages wouldn't be shown in their localized form
Evan Schoenberg
parents: 3161
diff changeset
   755
					   [secondaryString rangeOfString:[NSString stringWithUTF8String:_("Not logged in")]].location != NSNotFound) {
700131f4c0b6 Fix a localization problem in which these substituted error messages wouldn't be shown in their localized form
Evan Schoenberg
parents: 3161
diff changeset
   756
				description = AILocalizedString(@"Connection error.",nil);
700131f4c0b6 Fix a localization problem in which these substituted error messages wouldn't be shown in their localized form
Evan Schoenberg
parents: 3161
diff changeset
   757
				
700131f4c0b6 Fix a localization problem in which these substituted error messages wouldn't be shown in their localized form
Evan Schoenberg
parents: 3161
diff changeset
   758
			} else if ([secondaryString rangeOfString:[NSString stringWithUTF8String:_("Refused by client")]].location != NSNotFound) {
700131f4c0b6 Fix a localization problem in which these substituted error messages wouldn't be shown in their localized form
Evan Schoenberg
parents: 3161
diff changeset
   759
				description = AILocalizedString(@"Your message was refused by the other user.",nil);
700131f4c0b6 Fix a localization problem in which these substituted error messages wouldn't be shown in their localized form
Evan Schoenberg
parents: 3161
diff changeset
   760
				
700131f4c0b6 Fix a localization problem in which these substituted error messages wouldn't be shown in their localized form
Evan Schoenberg
parents: 3161
diff changeset
   761
			} else if ([secondaryString rangeOfString:[NSString stringWithUTF8String:_("Reply too big")]].location != NSNotFound) {
700131f4c0b6 Fix a localization problem in which these substituted error messages wouldn't be shown in their localized form
Evan Schoenberg
parents: 3161
diff changeset
   762
				description = AILocalizedString(@"Your message was too big.",nil);
700131f4c0b6 Fix a localization problem in which these substituted error messages wouldn't be shown in their localized form
Evan Schoenberg
parents: 3161
diff changeset
   763
				
700131f4c0b6 Fix a localization problem in which these substituted error messages wouldn't be shown in their localized form
Evan Schoenberg
parents: 3161
diff changeset
   764
			} else if ([secondaryString rangeOfString:[NSString stringWithUTF8String:_("In local permit/deny")]].location != NSNotFound) {
700131f4c0b6 Fix a localization problem in which these substituted error messages wouldn't be shown in their localized form
Evan Schoenberg
parents: 3161
diff changeset
   765
				description = AILocalizedString(@"The other user is in your deny list.",nil);
700131f4c0b6 Fix a localization problem in which these substituted error messages wouldn't be shown in their localized form
Evan Schoenberg
parents: 3161
diff changeset
   766
				
700131f4c0b6 Fix a localization problem in which these substituted error messages wouldn't be shown in their localized form
Evan Schoenberg
parents: 3161
diff changeset
   767
			} else if ([secondaryString rangeOfString:[NSString stringWithUTF8String:_("Too evil")]].location != NSNotFound) {
700131f4c0b6 Fix a localization problem in which these substituted error messages wouldn't be shown in their localized form
Evan Schoenberg
parents: 3161
diff changeset
   768
				description = AILocalizedString(@"Warning level is too high.",nil);
700131f4c0b6 Fix a localization problem in which these substituted error messages wouldn't be shown in their localized form
Evan Schoenberg
parents: 3161
diff changeset
   769
				
700131f4c0b6 Fix a localization problem in which these substituted error messages wouldn't be shown in their localized form
Evan Schoenberg
parents: 3161
diff changeset
   770
			} else if ([secondaryString rangeOfString:[NSString stringWithUTF8String:_("User temporarily unavailable")]].location != NSNotFound) {
700131f4c0b6 Fix a localization problem in which these substituted error messages wouldn't be shown in their localized form
Evan Schoenberg
parents: 3161
diff changeset
   771
				description = AILocalizedString(@"The other user is temporarily unavailable.",nil);
700131f4c0b6 Fix a localization problem in which these substituted error messages wouldn't be shown in their localized form
Evan Schoenberg
parents: 3161
diff changeset
   772
			}
700131f4c0b6 Fix a localization problem in which these substituted error messages wouldn't be shown in their localized form
Evan Schoenberg
parents: 3161
diff changeset
   773
		}
700131f4c0b6 Fix a localization problem in which these substituted error messages wouldn't be shown in their localized form
Evan Schoenberg
parents: 3161
diff changeset
   774
		
700131f4c0b6 Fix a localization problem in which these substituted error messages wouldn't be shown in their localized form
Evan Schoenberg
parents: 3161
diff changeset
   775
		if (!description)
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   776
			description = AILocalizedString(@"No reason was given.",nil);
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   777
    }
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   778
	
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   779
	//If we didn't grab a translated version, at least display the English version Purple supplied
100
68210ab2807a sed is evil. All [adium *Controller]s are now adium.*Controller.
David Smith
parents: 95
diff changeset
   780
	[adium.interfaceController handleMessage:([errorMessage length] ? errorMessage : primaryString)
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   781
							   withDescription:([description length] ? description : ([secondaryString length] ? secondaryString : @"") )
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   782
							   withWindowTitle:titleString];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   783
	
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   784
	return NULL;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   785
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   786
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   787
/* XXX ugly */
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   788
- (void *)handleNotifyFormattedWithTitle:(const char *)title primary:(const char *)primary secondary:(const char *)secondary text:(const char *)text
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   789
{
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   790
	NSString *titleString = (title ? [NSString stringWithUTF8String:title] : nil);
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   791
	NSString *primaryString = (primary ? [NSString stringWithUTF8String:primary] : nil);
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   792
	
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   793
	if (!titleString) {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   794
		titleString = primaryString;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   795
		primaryString = nil;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   796
	}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   797
	
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   798
	NSString *secondaryString = (secondary ? [NSString stringWithUTF8String:secondary] : nil);
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   799
	if (!primaryString) {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   800
		primaryString = secondaryString;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   801
		secondaryString = nil;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   802
	}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   803
	
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   804
	static AIHTMLDecoder	*notifyFormattedHTMLDecoder = nil;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   805
	if (!notifyFormattedHTMLDecoder) notifyFormattedHTMLDecoder = [[AIHTMLDecoder decoder] retain];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   806
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   807
	NSString	*textString = (text ? [NSString stringWithUTF8String:text] : nil); 
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   808
	if (textString) textString = [[notifyFormattedHTMLDecoder decodeHTML:textString] string];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   809
	
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   810
	NSString	*description = nil;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   811
	if ([textString length] && [secondaryString length]) {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   812
		description = [NSString stringWithFormat:@"%@\n\n%@",secondaryString,textString];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   813
		
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   814
	} else if (textString) {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   815
		description = textString;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   816
		
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   817
	} else if (secondaryString) {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   818
		description = secondaryString;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   819
		
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   820
	}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   821
	
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   822
	NSString	*message = primaryString;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   823
	
100
68210ab2807a sed is evil. All [adium *Controller]s are now adium.*Controller.
David Smith
parents: 95
diff changeset
   824
	[adium.interfaceController handleMessage:(message ? message : @"")
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   825
							   withDescription:(description ? description : @"")
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   826
							   withWindowTitle:(titleString ? titleString : @"")];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   827
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   828
	return NULL;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   829
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   830
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   831
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   832
#pragma mark File transfers
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   833
- (void)displayFileSendError
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   834
{
100
68210ab2807a sed is evil. All [adium *Controller]s are now adium.*Controller.
David Smith
parents: 95
diff changeset
   835
	[adium.interfaceController handleMessage:AILocalizedString(@"File Send Error",nil)
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   836
							   withDescription:AILocalizedString(@"An error was encoutered sending the file.",nil)
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   837
							   withWindowTitle:AILocalizedString(@"File Send Error",nil)];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   838
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   839
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   840
#pragma mark Thread accessors
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   841
- (void)disconnectAccount:(id)adiumAccount
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   842
{
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   843
	PurpleAccount *account = accountLookupFromAdiumAccount(adiumAccount);
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   844
	AILog(@"Setting %x disabled and offline (%s)...",account,
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   845
		  purple_status_type_get_id(purple_account_get_status_type_with_primitive(account, PURPLE_STATUS_OFFLINE)));
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   846
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   847
	purple_account_set_enabled(account, "Adium", NO);
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   848
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   849
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   850
- (void)registerAccount:(id)adiumAccount
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   851
{
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   852
	purple_account_set_register_callback(accountLookupFromAdiumAccount(adiumAccount), adiumPurpleAccountRegisterCb, adiumAccount);
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   853
	purple_account_register(accountLookupFromAdiumAccount(adiumAccount));
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   854
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   855
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   856
static void purpleUnregisterCb(PurpleAccount *account, gboolean success, void *user_data) {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   857
	[(CBPurpleAccount*)user_data unregisteredAccount:success?YES:NO];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   858
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   859
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   860
- (void)unregisterAccount:(id)adiumAccount
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   861
{
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   862
	purple_account_unregister(accountLookupFromAdiumAccount(adiumAccount), purpleUnregisterCb, adiumAccount);
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   863
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   864
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   865
//Called on the purple thread, actually performs the specified command (it should have already been tested by 
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   866
//attemptPurpleCommandOnMessage:... below.
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   867
- (BOOL)doCommand:(NSString *)originalMessage
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   868
			fromAccount:(id)sourceAccount
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   869
				 inChat:(AIChat *)chat
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   870
{
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   871
	PurpleConversation	*conv = convLookupFromChat(chat, sourceAccount);
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   872
	PurpleCmdStatus		status;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   873
	char				*markup, *error;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   874
	const char			*cmd;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   875
	BOOL				didCommand = NO;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   876
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   877
	if (!conv || ([originalMessage length] < 2)) return NO;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   878
	
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   879
	cmd = [originalMessage UTF8String];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   880
	
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   881
	//cmd+1 will be the cmd without the leading character, which should be "/"
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   882
	markup = g_markup_escape_text(cmd+1, -1);
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   883
	status = purple_cmd_do_command(conv, cmd+1, markup, &error);
1621
f882030d6d0e Don't leak every command executed.
Zachary West <zacw@adiumx.com>
parents: 1442
diff changeset
   884
	g_free(markup);
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   885
	
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   886
	//The only error status which is possible now is either 
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   887
	switch (status) {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   888
		case PURPLE_CMD_STATUS_FAILED:
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   889
		{
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   890
			purple_conv_present_error(purple_conversation_get_name(conv), purple_conversation_get_account(conv), "Command failed");
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   891
			didCommand = YES;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   892
			break;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   893
		}	
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   894
		case PURPLE_CMD_STATUS_WRONG_ARGS:
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   895
		{
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   896
			purple_conv_present_error(purple_conversation_get_name(conv), purple_conversation_get_account(conv), "Wrong number of arguments");
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   897
			didCommand = YES;			
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   898
			break;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   899
		}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   900
		case PURPLE_CMD_STATUS_OK:
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   901
			didCommand = YES;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   902
			break;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   903
		case PURPLE_CMD_STATUS_NOT_FOUND:
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   904
		case PURPLE_CMD_STATUS_WRONG_TYPE:
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   905
		case PURPLE_CMD_STATUS_WRONG_PRPL:
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   906
			/* Ignore this command and let the message send; the user probably doesn't even know what they typed is a command */
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   907
			didCommand = NO;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   908
			break;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   909
	}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   910
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   911
	return didCommand;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   912
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   913
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   914
/*!
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   915
 * @brief Check a message for purple / commands=
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   916
 *
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   917
 * @result YES if a command was performed; NO if it was not
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   918
 */
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   919
- (BOOL)attemptPurpleCommandOnMessage:(NSString *)originalMessage fromAccount:(AIAccount *)sourceAccount inChat:(AIChat *)chat
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   920
{
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   921
	BOOL				didCommand = NO;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   922
	
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   923
	if ([originalMessage hasPrefix:@"/"]) {	
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   924
		didCommand = [self doCommand:originalMessage
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   925
						 fromAccount:sourceAccount
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   926
							  inChat:chat];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   927
	}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   928
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   929
	return didCommand;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   930
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   931
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   932
/*!
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   933
 * @brief Send a notification over a service which supports that
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   934
 *
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   935
 * This should not be called for an account whose service doesn't support sending notifications (check before calling).
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   936
 * Doing so will return without displaying an error; the message should be sent as a normal message in this case.
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   937
 *
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   938
 * @param type An AINotificationType.
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   939
 * @param sourceAccount The account from which to send
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   940
 * @param chat The chat in which to send the notification
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   941
 */
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   942
- (void)sendNotificationOfType:(AINotificationType)type
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   943
				   fromAccount:(id)sourceAccount
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   944
						inChat:(AIChat *)chat
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   945
{
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   946
	PurpleConversation	*conv = convLookupFromChat(chat,sourceAccount);
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   947
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   948
	purple_prpl_send_attention(purple_conversation_get_gc(conv),
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   949
							   purple_conversation_get_name(conv),
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   950
							   type);
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   951
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   952
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   953
//Returns YES if the message was sent (and should therefore be displayed).  Returns NO if it was not sent or was otherwise used.
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   954
- (void)sendEncodedMessage:(NSString *)encodedMessage
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   955
			   fromAccount:(id)sourceAccount
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   956
					inChat:(AIChat *)chat
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   957
				 withFlags:(PurpleMessageFlags)flags
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   958
{	
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   959
	const char *encodedMessageUTF8String;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   960
	
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   961
	if (encodedMessage && (encodedMessageUTF8String = [encodedMessage UTF8String])) {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   962
		PurpleConversation	*conv = convLookupFromChat(chat,sourceAccount);
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   963
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   964
		switch (purple_conversation_get_type(conv)) {				
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   965
			case PURPLE_CONV_TYPE_IM: {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   966
				PurpleConvIm			*im = purple_conversation_get_im_data(conv);
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   967
				purple_conv_im_send_with_flags(im, encodedMessageUTF8String, flags);
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   968
				break;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   969
			}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   970
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   971
			case PURPLE_CONV_TYPE_CHAT: {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   972
				PurpleConvChat	*purpleChat = purple_conversation_get_chat_data(conv);
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   973
				purple_conv_chat_send(purpleChat, encodedMessageUTF8String);
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   974
				break;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   975
			}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   976
			
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   977
			case PURPLE_CONV_TYPE_ANY:
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   978
				AILog(@"What in the world? Got PURPLE_CONV_TYPE_ANY.");
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   979
				break;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   980
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   981
			case PURPLE_CONV_TYPE_MISC:
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   982
			case PURPLE_CONV_TYPE_UNKNOWN:
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   983
				break;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   984
		}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   985
	} else {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   986
		AILog(@"*** Error encoding %@ to UTF8",encodedMessage);
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   987
	}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   988
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   989
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   990
- (void)sendTyping:(AITypingState)typingState inChat:(AIChat *)chat
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   991
{
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   992
	PurpleConversation *conv = convLookupFromChat(chat,nil);
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   993
	if (conv) {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   994
		//		BOOL isTyping = (([typingState intValue] == AINotTyping) ? FALSE : TRUE);
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   995
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   996
		PurpleTypingState purpleTypingState;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   997
		
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   998
		switch (typingState) {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   999
			case AINotTyping:
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1000
			default:
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1001
				purpleTypingState = PURPLE_NOT_TYPING;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1002
				break;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1003
			case AITyping:
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1004
				purpleTypingState = PURPLE_TYPING;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1005
				break;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1006
			case AIEnteredText:
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1007
				purpleTypingState = PURPLE_TYPED;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1008
				break;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1009
		}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1010
	
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1011
		serv_send_typing(purple_conversation_get_gc(conv),
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1012
						 purple_conversation_get_name(conv),
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1013
						 purpleTypingState);
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1014
	}	
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1015
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1016
2249
4e4e0005bbc2 Set the PurpleBuddy's alias when adding to the buddy list, which is how Pidgin operates.
Zachary West <zacw@adium.im>
parents: 2128
diff changeset
  1017
- (void)addUID:(NSString *)objectUID onAccount:(id)adiumAccount toGroup:(NSString *)groupName withAlias:(NSString *)alias
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1018
{
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1019
	PurpleAccount *account = accountLookupFromAdiumAccount(adiumAccount);
2249
4e4e0005bbc2 Set the PurpleBuddy's alias when adding to the buddy list, which is how Pidgin operates.
Zachary West <zacw@adium.im>
parents: 2128
diff changeset
  1020
	const char	*groupUTF8String, *buddyUTF8String, *aliasUTF8String;
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1021
	PurpleGroup	*group;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1022
	PurpleBuddy	*buddy;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1023
	
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1024
	//Find the group (Create if necessary)
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1025
	groupUTF8String = (groupName ? [groupName UTF8String] : "Buddies");
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1026
	if (!(group = purple_find_group(groupUTF8String))) {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1027
		group = purple_group_new(groupUTF8String);
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1028
		purple_blist_add_group(group, NULL);
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1029
	}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1030
	
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1031
	buddyUTF8String = [objectUID UTF8String];
2249
4e4e0005bbc2 Set the PurpleBuddy's alias when adding to the buddy list, which is how Pidgin operates.
Zachary West <zacw@adium.im>
parents: 2128
diff changeset
  1032
	aliasUTF8String = alias.length ? [alias UTF8String] : NULL;
2128
9992255c5007 Contact list support for moving contacts in multiple groups.
Zachary West <zacw@adium.im>
parents: 2093
diff changeset
  1033
	
9992255c5007 Contact list support for moving contacts in multiple groups.
Zachary West <zacw@adium.im>
parents: 2093
diff changeset
  1034
	// Find an existing buddy in the group.
9992255c5007 Contact list support for moving contacts in multiple groups.
Zachary West <zacw@adium.im>
parents: 2093
diff changeset
  1035
	buddy = purple_find_buddy_in_group(account, buddyUTF8String, group);
3516
9bc8dc826e36 Maybe this is to risky to include in 1.4.3.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3515
diff changeset
  1036
	if (!buddy) buddy = purple_buddy_new(account, buddyUTF8String, aliasUTF8String);
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1037
2249
4e4e0005bbc2 Set the PurpleBuddy's alias when adding to the buddy list, which is how Pidgin operates.
Zachary West <zacw@adium.im>
parents: 2128
diff changeset
  1038
	AILog(@"Adding buddy %s to group %s with alias %s",purple_buddy_get_name(buddy), group->name, aliasUTF8String);
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1039
3516
9bc8dc826e36 Maybe this is to risky to include in 1.4.3.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3515
diff changeset
  1040
	/* purple_blist_add_buddy() will move an existing contact serverside, but will not add a buddy serverside.
9bc8dc826e36 Maybe this is to risky to include in 1.4.3.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3515
diff changeset
  1041
	 * We're working with a new contact, hopefully, so we want to call serv_add_buddy() after modifying the purple list.
9bc8dc826e36 Maybe this is to risky to include in 1.4.3.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3515
diff changeset
  1042
	 * This is the order done in add_buddy_cb() in gtkblist.c */
9bc8dc826e36 Maybe this is to risky to include in 1.4.3.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3515
diff changeset
  1043
	purple_blist_add_buddy(buddy, NULL, group, NULL);
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1044
	purple_account_add_buddy(account, buddy);
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1045
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1046
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1047
- (void)removeUID:(NSString *)objectUID onAccount:(id)adiumAccount fromGroup:(NSString *)groupName
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1048
{
2128
9992255c5007 Contact list support for moving contacts in multiple groups.
Zachary West <zacw@adium.im>
parents: 2093
diff changeset
  1049
	const char	*groupUTF8String;
9992255c5007 Contact list support for moving contacts in multiple groups.
Zachary West <zacw@adium.im>
parents: 2093
diff changeset
  1050
	PurpleGroup	*group;
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1051
	
2128
9992255c5007 Contact list support for moving contacts in multiple groups.
Zachary West <zacw@adium.im>
parents: 2093
diff changeset
  1052
	// Find the right buddy; group -> buddy in group -> remove that buddy
9992255c5007 Contact list support for moving contacts in multiple groups.
Zachary West <zacw@adium.im>
parents: 2093
diff changeset
  1053
	
9992255c5007 Contact list support for moving contacts in multiple groups.
Zachary West <zacw@adium.im>
parents: 2093
diff changeset
  1054
	groupUTF8String = (groupName ? [groupName UTF8String] : "Buddies");
9992255c5007 Contact list support for moving contacts in multiple groups.
Zachary West <zacw@adium.im>
parents: 2093
diff changeset
  1055
	if ((group = purple_find_group(groupUTF8String))) {
9992255c5007 Contact list support for moving contacts in multiple groups.
Zachary West <zacw@adium.im>
parents: 2093
diff changeset
  1056
		PurpleAccount *account = accountLookupFromAdiumAccount(adiumAccount);
9992255c5007 Contact list support for moving contacts in multiple groups.
Zachary West <zacw@adium.im>
parents: 2093
diff changeset
  1057
		PurpleBuddy 	*buddy;
9992255c5007 Contact list support for moving contacts in multiple groups.
Zachary West <zacw@adium.im>
parents: 2093
diff changeset
  1058
		
9992255c5007 Contact list support for moving contacts in multiple groups.
Zachary West <zacw@adium.im>
parents: 2093
diff changeset
  1059
		if ((buddy = purple_find_buddy_in_group(account, [objectUID UTF8String], group))) {
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1060
			/* Remove this contact from the server-side and purple-side lists. 
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1061
			 * Updating purpleside does not change the server.
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1062
			 *
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1063
			 * Purple has a commented XXX as to whether this order or the reverse (blist, then serv) is correct.
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1064
			 * We'll use the order which purple uses as of purple 1.1.4. */
2128
9992255c5007 Contact list support for moving contacts in multiple groups.
Zachary West <zacw@adium.im>
parents: 2093
diff changeset
  1065
			
9992255c5007 Contact list support for moving contacts in multiple groups.
Zachary West <zacw@adium.im>
parents: 2093
diff changeset
  1066
			AILog(@"Removing buddy %s from group %s", purple_buddy_get_name(buddy), purple_group_get_name(purple_buddy_get_group(buddy)));
9992255c5007 Contact list support for moving contacts in multiple groups.
Zachary West <zacw@adium.im>
parents: 2093
diff changeset
  1067
			
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1068
			purple_account_remove_buddy(account, buddy, group);
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1069
			purple_blist_remove_buddy(buddy);
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1070
		}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1071
	}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1072
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1073
2249
4e4e0005bbc2 Set the PurpleBuddy's alias when adding to the buddy list, which is how Pidgin operates.
Zachary West <zacw@adium.im>
parents: 2128
diff changeset
  1074
- (void)moveUID:(NSString *)objectUID onAccount:(id)adiumAccount fromGroups:(NSSet *)oldGroups toGroups:(NSSet *)groupNames withAlias:(NSString *)alias;
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1075
{
2331
38629538cb0c When moving a contact, perform an actual move of the contact, instead of an "add to new group" + "remove from old group".
Zachary West <zacw@adium.im>
parents: 2249
diff changeset
  1076
	PurpleAccount *account = accountLookupFromAdiumAccount(adiumAccount);
38629538cb0c When moving a contact, perform an actual move of the contact, instead of an "add to new group" + "remove from old group".
Zachary West <zacw@adium.im>
parents: 2249
diff changeset
  1077
	
709
0ef6a63599ec More scary multigroups changes. It was actually working at one point, but then I broke it again. Progress though :)
David Smith
parents: 703
diff changeset
  1078
	for (NSString *groupName in groupNames) {
2128
9992255c5007 Contact list support for moving contacts in multiple groups.
Zachary West <zacw@adium.im>
parents: 2093
diff changeset
  1079
		if (!oldGroups.count) {
9992255c5007 Contact list support for moving contacts in multiple groups.
Zachary West <zacw@adium.im>
parents: 2093
diff changeset
  1080
			// If we don't have any source groups, silently turn this into an add.
3076
f1841622cf0e More debug logging for group changes
Evan Schoenberg
parents: 2331
diff changeset
  1081
			AILog(@"Move of %@ failed because we have no oldGroups; adding instead", objectUID);
2249
4e4e0005bbc2 Set the PurpleBuddy's alias when adding to the buddy list, which is how Pidgin operates.
Zachary West <zacw@adium.im>
parents: 2128
diff changeset
  1082
			[self addUID:objectUID onAccount:adiumAccount toGroup:groupName withAlias:alias];
2128
9992255c5007 Contact list support for moving contacts in multiple groups.
Zachary West <zacw@adium.im>
parents: 2093
diff changeset
  1083
			continue;
709
0ef6a63599ec More scary multigroups changes. It was actually working at one point, but then I broke it again. Progress though :)
David Smith
parents: 703
diff changeset
  1084
		}
0ef6a63599ec More scary multigroups changes. It was actually working at one point, but then I broke it again. Progress though :)
David Smith
parents: 703
diff changeset
  1085
		
2331
38629538cb0c When moving a contact, perform an actual move of the contact, instead of an "add to new group" + "remove from old group".
Zachary West <zacw@adium.im>
parents: 2249
diff changeset
  1086
		PurpleGroup *group;
38629538cb0c When moving a contact, perform an actual move of the contact, instead of an "add to new group" + "remove from old group".
Zachary West <zacw@adium.im>
parents: 2249
diff changeset
  1087
		const char *groupUTF8String = (groupName ? [groupName UTF8String] : "Buddies");
38629538cb0c When moving a contact, perform an actual move of the contact, instead of an "add to new group" + "remove from old group".
Zachary West <zacw@adium.im>
parents: 2249
diff changeset
  1088
		
38629538cb0c When moving a contact, perform an actual move of the contact, instead of an "add to new group" + "remove from old group".
Zachary West <zacw@adium.im>
parents: 2249
diff changeset
  1089
		// Find the PurpleGroup, otherwise create a new one.
38629538cb0c When moving a contact, perform an actual move of the contact, instead of an "add to new group" + "remove from old group".
Zachary West <zacw@adium.im>
parents: 2249
diff changeset
  1090
		if (!(group = purple_find_group(groupUTF8String))) {
38629538cb0c When moving a contact, perform an actual move of the contact, instead of an "add to new group" + "remove from old group".
Zachary West <zacw@adium.im>
parents: 2249
diff changeset
  1091
			group = purple_group_new(groupUTF8String);
38629538cb0c When moving a contact, perform an actual move of the contact, instead of an "add to new group" + "remove from old group".
Zachary West <zacw@adium.im>
parents: 2249
diff changeset
  1092
			purple_blist_add_group(group, NULL);
38629538cb0c When moving a contact, perform an actual move of the contact, instead of an "add to new group" + "remove from old group".
Zachary West <zacw@adium.im>
parents: 2249
diff changeset
  1093
		}
38629538cb0c When moving a contact, perform an actual move of the contact, instead of an "add to new group" + "remove from old group".
Zachary West <zacw@adium.im>
parents: 2249
diff changeset
  1094
		
2128
9992255c5007 Contact list support for moving contacts in multiple groups.
Zachary West <zacw@adium.im>
parents: 2093
diff changeset
  1095
		for (NSString *sourceGroupName in oldGroups) {
2331
38629538cb0c When moving a contact, perform an actual move of the contact, instead of an "add to new group" + "remove from old group".
Zachary West <zacw@adium.im>
parents: 2249
diff changeset
  1096
			PurpleGroup *oldGroup;
38629538cb0c When moving a contact, perform an actual move of the contact, instead of an "add to new group" + "remove from old group".
Zachary West <zacw@adium.im>
parents: 2249
diff changeset
  1097
			
38629538cb0c When moving a contact, perform an actual move of the contact, instead of an "add to new group" + "remove from old group".
Zachary West <zacw@adium.im>
parents: 2249
diff changeset
  1098
			if ((oldGroup = purple_find_group([sourceGroupName UTF8String]))) {
38629538cb0c When moving a contact, perform an actual move of the contact, instead of an "add to new group" + "remove from old group".
Zachary West <zacw@adium.im>
parents: 2249
diff changeset
  1099
				PurpleBuddy *buddy;	
38629538cb0c When moving a contact, perform an actual move of the contact, instead of an "add to new group" + "remove from old group".
Zachary West <zacw@adium.im>
parents: 2249
diff changeset
  1100
				
38629538cb0c When moving a contact, perform an actual move of the contact, instead of an "add to new group" + "remove from old group".
Zachary West <zacw@adium.im>
parents: 2249
diff changeset
  1101
				if ((buddy = purple_find_buddy_in_group(account, [objectUID UTF8String], oldGroup))) {
38629538cb0c When moving a contact, perform an actual move of the contact, instead of an "add to new group" + "remove from old group".
Zachary West <zacw@adium.im>
parents: 2249
diff changeset
  1102
					// Perform the add to the new group. This will turn into a move, and will update serverside.
3083
a960a9aa710d Implemented a workaround for an annoying Yahoo service bug when moving a contact between two groups, both of which already contain it. A better solution would be at the protocol level; a libpurple ticket should be filed regarding this at some point. Fixes #13871
Evan Schoenberg
parents: 3081
diff changeset
  1103
a960a9aa710d Implemented a workaround for an annoying Yahoo service bug when moving a contact between two groups, both of which already contain it. A better solution would be at the protocol level; a libpurple ticket should be filed regarding this at some point. Fixes #13871
Evan Schoenberg
parents: 3081
diff changeset
  1104
					if (strcmp(purple_account_get_protocol_id(account), "prpl-yahoo") == 0) {
a960a9aa710d Implemented a workaround for an annoying Yahoo service bug when moving a contact between two groups, both of which already contain it. A better solution would be at the protocol level; a libpurple ticket should be filed regarding this at some point. Fixes #13871
Evan Schoenberg
parents: 3081
diff changeset
  1105
						/* XXX File a bug report with the need for this special-case w/ libpurple -evands 10/14/10 */
a960a9aa710d Implemented a workaround for an annoying Yahoo service bug when moving a contact between two groups, both of which already contain it. A better solution would be at the protocol level; a libpurple ticket should be filed regarding this at some point. Fixes #13871
Evan Schoenberg
parents: 3081
diff changeset
  1106
a960a9aa710d Implemented a workaround for an annoying Yahoo service bug when moving a contact between two groups, both of which already contain it. A better solution would be at the protocol level; a libpurple ticket should be filed regarding this at some point. Fixes #13871
Evan Schoenberg
parents: 3081
diff changeset
  1107
						/* Work around a Yahoo! bug in which buddies in multiple groups can't be moved properly.
a960a9aa710d Implemented a workaround for an annoying Yahoo service bug when moving a contact between two groups, both of which already contain it. A better solution would be at the protocol level; a libpurple ticket should be filed regarding this at some point. Fixes #13871
Evan Schoenberg
parents: 3081
diff changeset
  1108
						 *
a960a9aa710d Implemented a workaround for an annoying Yahoo service bug when moving a contact between two groups, both of which already contain it. A better solution would be at the protocol level; a libpurple ticket should be filed regarding this at some point. Fixes #13871
Evan Schoenberg
parents: 3081
diff changeset
  1109
						 * Traverse all buddies on this account.
a960a9aa710d Implemented a workaround for an annoying Yahoo service bug when moving a contact between two groups, both of which already contain it. A better solution would be at the protocol level; a libpurple ticket should be filed regarding this at some point. Fixes #13871
Evan Schoenberg
parents: 3081
diff changeset
  1110
						 * If the buddy is in the old group (it must be, for us to reach this point given the if
a960a9aa710d Implemented a workaround for an annoying Yahoo service bug when moving a contact between two groups, both of which already contain it. A better solution would be at the protocol level; a libpurple ticket should be filed regarding this at some point. Fixes #13871
Evan Schoenberg
parents: 3081
diff changeset
  1111
						 * statement above) and is also in another group, we need to remove it from the old group before
a960a9aa710d Implemented a workaround for an annoying Yahoo service bug when moving a contact between two groups, both of which already contain it. A better solution would be at the protocol level; a libpurple ticket should be filed regarding this at some point. Fixes #13871
Evan Schoenberg
parents: 3081
diff changeset
  1112
						 * this move. Otherwise, it won't work. However, if we remove it from the old group and it *isn't* in 
a960a9aa710d Implemented a workaround for an annoying Yahoo service bug when moving a contact between two groups, both of which already contain it. A better solution would be at the protocol level; a libpurple ticket should be filed regarding this at some point. Fixes #13871
Evan Schoenberg
parents: 3081
diff changeset
  1113
						 * another group already, Yahoo will force reauthorization, which is ugly.  */
a960a9aa710d Implemented a workaround for an annoying Yahoo service bug when moving a contact between two groups, both of which already contain it. A better solution would be at the protocol level; a libpurple ticket should be filed regarding this at some point. Fixes #13871
Evan Schoenberg
parents: 3081
diff changeset
  1114
						GSList	*buddies = purple_find_buddies(account, [objectUID UTF8String]);
a960a9aa710d Implemented a workaround for an annoying Yahoo service bug when moving a contact between two groups, both of which already contain it. A better solution would be at the protocol level; a libpurple ticket should be filed regarding this at some point. Fixes #13871
Evan Schoenberg
parents: 3081
diff changeset
  1115
						
a960a9aa710d Implemented a workaround for an annoying Yahoo service bug when moving a contact between two groups, both of which already contain it. A better solution would be at the protocol level; a libpurple ticket should be filed regarding this at some point. Fixes #13871
Evan Schoenberg
parents: 3081
diff changeset
  1116
						BOOL isInGroupBesidesOldGroup = NO;
a960a9aa710d Implemented a workaround for an annoying Yahoo service bug when moving a contact between two groups, both of which already contain it. A better solution would be at the protocol level; a libpurple ticket should be filed regarding this at some point. Fixes #13871
Evan Schoenberg
parents: 3081
diff changeset
  1117
						for (GSList	*bb = buddies; bb != NULL; bb = bb->next) {
a960a9aa710d Implemented a workaround for an annoying Yahoo service bug when moving a contact between two groups, both of which already contain it. A better solution would be at the protocol level; a libpurple ticket should be filed regarding this at some point. Fixes #13871
Evan Schoenberg
parents: 3081
diff changeset
  1118
							PurpleBuddy *aBuddy = (PurpleBuddy *)bb->data;
a960a9aa710d Implemented a workaround for an annoying Yahoo service bug when moving a contact between two groups, both of which already contain it. A better solution would be at the protocol level; a libpurple ticket should be filed regarding this at some point. Fixes #13871
Evan Schoenberg
parents: 3081
diff changeset
  1119
							if (purple_buddy_get_group(aBuddy) != oldGroup) {
a960a9aa710d Implemented a workaround for an annoying Yahoo service bug when moving a contact between two groups, both of which already contain it. A better solution would be at the protocol level; a libpurple ticket should be filed regarding this at some point. Fixes #13871
Evan Schoenberg
parents: 3081
diff changeset
  1120
								isInGroupBesidesOldGroup = YES;
a960a9aa710d Implemented a workaround for an annoying Yahoo service bug when moving a contact between two groups, both of which already contain it. A better solution would be at the protocol level; a libpurple ticket should be filed regarding this at some point. Fixes #13871
Evan Schoenberg
parents: 3081
diff changeset
  1121
							}
a960a9aa710d Implemented a workaround for an annoying Yahoo service bug when moving a contact between two groups, both of which already contain it. A better solution would be at the protocol level; a libpurple ticket should be filed regarding this at some point. Fixes #13871
Evan Schoenberg
parents: 3081
diff changeset
  1122
						}
a960a9aa710d Implemented a workaround for an annoying Yahoo service bug when moving a contact between two groups, both of which already contain it. A better solution would be at the protocol level; a libpurple ticket should be filed regarding this at some point. Fixes #13871
Evan Schoenberg
parents: 3081
diff changeset
  1123
	
a960a9aa710d Implemented a workaround for an annoying Yahoo service bug when moving a contact between two groups, both of which already contain it. A better solution would be at the protocol level; a libpurple ticket should be filed regarding this at some point. Fixes #13871
Evan Schoenberg
parents: 3081
diff changeset
  1124
						if (isInGroupBesidesOldGroup) {
a960a9aa710d Implemented a workaround for an annoying Yahoo service bug when moving a contact between two groups, both of which already contain it. A better solution would be at the protocol level; a libpurple ticket should be filed regarding this at some point. Fixes #13871
Evan Schoenberg
parents: 3081
diff changeset
  1125
							purple_account_remove_buddy(account, buddy, oldGroup);
a960a9aa710d Implemented a workaround for an annoying Yahoo service bug when moving a contact between two groups, both of which already contain it. A better solution would be at the protocol level; a libpurple ticket should be filed regarding this at some point. Fixes #13871
Evan Schoenberg
parents: 3081
diff changeset
  1126
							AILog(@"Removed because it met the Yahoo! workaround criteria");
a960a9aa710d Implemented a workaround for an annoying Yahoo service bug when moving a contact between two groups, both of which already contain it. A better solution would be at the protocol level; a libpurple ticket should be filed regarding this at some point. Fixes #13871
Evan Schoenberg
parents: 3081
diff changeset
  1127
						}
a960a9aa710d Implemented a workaround for an annoying Yahoo service bug when moving a contact between two groups, both of which already contain it. A better solution would be at the protocol level; a libpurple ticket should be filed regarding this at some point. Fixes #13871
Evan Schoenberg
parents: 3081
diff changeset
  1128
a960a9aa710d Implemented a workaround for an annoying Yahoo service bug when moving a contact between two groups, both of which already contain it. A better solution would be at the protocol level; a libpurple ticket should be filed regarding this at some point. Fixes #13871
Evan Schoenberg
parents: 3081
diff changeset
  1129
					}
a960a9aa710d Implemented a workaround for an annoying Yahoo service bug when moving a contact between two groups, both of which already contain it. A better solution would be at the protocol level; a libpurple ticket should be filed regarding this at some point. Fixes #13871
Evan Schoenberg
parents: 3081
diff changeset
  1130
					
2331
38629538cb0c When moving a contact, perform an actual move of the contact, instead of an "add to new group" + "remove from old group".
Zachary West <zacw@adium.im>
parents: 2249
diff changeset
  1131
					purple_blist_add_buddy(buddy, NULL, group, NULL);
38629538cb0c When moving a contact, perform an actual move of the contact, instead of an "add to new group" + "remove from old group".
Zachary West <zacw@adium.im>
parents: 2249
diff changeset
  1132
					// Continue so we avoid the "add to group" code below.
38629538cb0c When moving a contact, perform an actual move of the contact, instead of an "add to new group" + "remove from old group".
Zachary West <zacw@adium.im>
parents: 2249
diff changeset
  1133
					continue;
38629538cb0c When moving a contact, perform an actual move of the contact, instead of an "add to new group" + "remove from old group".
Zachary West <zacw@adium.im>
parents: 2249
diff changeset
  1134
				}
38629538cb0c When moving a contact, perform an actual move of the contact, instead of an "add to new group" + "remove from old group".
Zachary West <zacw@adium.im>
parents: 2249
diff changeset
  1135
			}
38629538cb0c When moving a contact, perform an actual move of the contact, instead of an "add to new group" + "remove from old group".
Zachary West <zacw@adium.im>
parents: 2249
diff changeset
  1136
			
38629538cb0c When moving a contact, perform an actual move of the contact, instead of an "add to new group" + "remove from old group".
Zachary West <zacw@adium.im>
parents: 2249
diff changeset
  1137
			// If we got this far, the move failed; turn into an add.
3076
f1841622cf0e More debug logging for group changes
Evan Schoenberg
parents: 2331
diff changeset
  1138
			AILog(@"Move of %@ failed; adding instead", objectUID);
2249
4e4e0005bbc2 Set the PurpleBuddy's alias when adding to the buddy list, which is how Pidgin operates.
Zachary West <zacw@adium.im>
parents: 2128
diff changeset
  1139
			[self addUID:objectUID onAccount:adiumAccount toGroup:groupName withAlias:alias];
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1140
		}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1141
	}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1142
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1143
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1144
- (void)renameGroup:(NSString *)oldGroupName onAccount:(id)adiumAccount to:(NSString *)newGroupName
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1145
{
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1146
    PurpleGroup *group = purple_find_group([oldGroupName UTF8String]);
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1147
	
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
  1148
	//If we don't have a group with this name, just ignore the rename request