-
Notifications
You must be signed in to change notification settings - Fork 2
/
XMPPDefaultHandler.m
67 lines (61 loc) · 1.91 KB
/
XMPPDefaultHandler.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
//
// XMPPDefaultHandler.m
// Jabber
//
// Created by David Chisnall on Sun May 23 2004.
// Copyright (c) 2004 __MyCompanyName__. All rights reserved.
//
#import "XMPPDefaultHandler.h"
#import "XMPPConversation.h"
#import "XMPPRoster.h"
//#import "MessageWindowController.h"
@implementation XMPPDefaultHandler
- (id) initWithAccount:(XMPPAccount*)_account
{
self = [self init];
if(self == nil)
{
return nil;
}
account = _account;
return self;
}
- (id) init
{
self = [super init];
if(self == nil)
{
return nil;
}
account = nil;
return self;
}
- (void) handleMessage:(XMPPMessage*)aMessage
{
JID * jid = [aMessage correspondent];
XMPPPerson * person = [[account roster] personForJID:jid];
XMPPConversation * conversation = [XMPPConversation conversationForPerson:person];
if(conversation == nil)
{
//TODO: Stop this going wrong when person is not a person
conversation = [XMPPConversation conversationWithPerson:person
forAccount:account];
//Notify the app that a new conversation has been created
NSNotificationCenter * local = [NSNotificationCenter defaultCenter];
[local postNotificationName:@"XMPPNewConversationStartedNotification"
object:account
userInfo:[NSDictionary dictionaryWithObject:conversation forKey:@"XMPPConversation"]];
}
if(![[conversation remoteJID] isEqualToJID:jid])
{
[conversation setJID:jid];
}
[conversation handleMessage:aMessage];
}
- (void) handlePresence:(XMPPPresence*)aPresence
{
}
- (void) handleInfoQuery:(XMPPInfoQueryStanza*)anIq
{
}
@end