ObjXMPP  Diff

Differences From Artifact [7146d5897e]:

To Artifact [2af3d0c968]:


1
2

3
4

5
6
7
8
9
10
11
1
2
3
4

5
6
7
8
9
10
11
12


+

-
+







/*
 * Copyright (c) 2013, Florian Zeitz <florob@babelmonkeys.de>
 * Copyright (c) 2013, 2016, Jonathan Schleifer <js@heap.zone>
 *
 * https://webkeks.org/git/?p=objxmpp.git
 * https://heap.zone/git/?p=objxmpp.git
 *
 * Permission to use, copy, modify, and/or distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice is present in all copies.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
22
23
24
25
26
27



28
29
30
31
32
33
34
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38







+
+
+







 */

#import "XMPPContact.h"
#import "XMPPMessage.h"
#import "XMPPConnection.h"

@implementation XMPPContact
@synthesize rosterItem = _rosterItem;
@synthesize presences = _presences;

- init
{
	self = [super init];

	@try {
		_presences = [[OFMutableDictionary alloc] init];
	} @catch (id e) {
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72



73
74
75
76
77
78
79
46
47
48
49
50
51
52










53
54
55
56
57
58
59
60
61
62
63
64
65

66
67
68
69
70
71
72
73
74
75







-
-
-
-
-
-
-
-
-
-













-
+
+
+







- (void)dealloc
{
	[_presences release];

	[super dealloc];
}

- (XMPPRosterItem*)rosterItem
{
	OF_GETTER(_rosterItem, true)
}

- (OFDictionary*)presences
{
	OF_GETTER(_presences, true)
}

- (void)sendMessage: (XMPPMessage*)message
	 connection: (XMPPConnection*)connection
{
	if (_lockedOnJID == nil)
		[message setTo: [_rosterItem JID]];
	else
		[message setTo: _lockedOnJID];

	[connection sendStanza: message];
}

- (void)XMPP_setRosterItem: (XMPPRosterItem*)rosterItem
{
	OF_SETTER(_rosterItem, rosterItem, true, 0);
	XMPPRosterItem *old = _rosterItem;
	_rosterItem = [rosterItem retain];
	[old release];
}

- (void)XMPP_setPresence: (XMPPPresence*)presence
		resource: (OFString*)resource
{
	if (resource != nil)
		[_presences setObject: presence
95
96
97
98
99
100
101
102



103
104
91
92
93
94
95
96
97

98
99
100
101
102







-
+
+
+


	}

	[self XMPP_setLockedOnJID: nil];
}

- (void)XMPP_setLockedOnJID: (XMPPJID*)JID;
{
	OF_SETTER(_lockedOnJID, JID, true, 0);
	XMPPJID *old = _lockedOnJID;
	_lockedOnJID = [JID retain];
	[old release];
}
@end