ObjXMPP  Check-in [e53970f55f]

Overview
Comment:Change how roster items are stored.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: e53970f55fec1608d6d34ec0d29842c942146a926af29cc1bf5c172048021ed3
User & Date: js on 2011-04-01 01:09:04
Other Links: manifest | tags
Context
2011-04-01
01:14
Add convenience header and method. check-in: 6c757fb3c0 user: js tags: trunk
01:09
Change how roster items are stored. check-in: e53970f55f user: js tags: trunk
2011-03-31
12:25
Adjust to newest ObjFW and greatly improve XML handling. check-in: 423434d147 user: js tags: trunk
Changes

Modified configure.ac from [cc022bbe90] to [e73fb2f584].

55
56
57
58
59
60
61
62
63
64
BUILDSYS_TOUCH_DEPS

dnl We don't call AC_PROG_CPP, but only AC_PROG_OBJCPP and set CPP to OBJCPP
dnl and add OBJCPPA.FLAGS to CPPFLAGS, thus we need to AC_SUBST these ourself
AC_SUBST(CPP)
AC_SUBST(CPPFLAGS)

AC_SUBST(PACKAGE, ObjFW)
AC_CONFIG_FILES([buildsys.mk extra.mk])
AC_OUTPUT







|


55
56
57
58
59
60
61
62
63
64
BUILDSYS_TOUCH_DEPS

dnl We don't call AC_PROG_CPP, but only AC_PROG_OBJCPP and set CPP to OBJCPP
dnl and add OBJCPPA.FLAGS to CPPFLAGS, thus we need to AC_SUBST these ourself
AC_SUBST(CPP)
AC_SUBST(CPPFLAGS)

AC_SUBST(PACKAGE, ObjXMPP)
AC_CONFIG_FILES([buildsys.mk extra.mk])
AC_OUTPUT

Modified src/XMPPRoster.h from [6e37e7971b] to [1f83f6aa00].

24
25
26
27
28
29
30
31
32
33
34
35
36

37
38
39
40
41

@class XMPPConnection;
@class XMPPRosterItem;

@interface XMPPRoster: OFObject
{
	XMPPConnection *connection;
	OFMutableDictionary *groups;
}

- initWithConnection: (XMPPConnection*)conn;
- (void)XMPP_addRosterItem: (XMPPRosterItem*)rosterItem;
- (OFArray*)groups;

- (OFArray*)rosterItemsInGroup: (OFString*)group;
- (void)addRosterItem: (XMPPRosterItem*)rosterItem;
- (void)updateRosterItem: (XMPPRosterItem*)rosterItem;
- (void)deleteRosterItem: (XMPPRosterItem*)rosterItem;
@end







|




|
>
|




24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42

@class XMPPConnection;
@class XMPPRosterItem;

@interface XMPPRoster: OFObject
{
	XMPPConnection *connection;
	OFMutableDictionary *rosterItems;
}

- initWithConnection: (XMPPConnection*)conn;
- (void)XMPP_addRosterItem: (XMPPRosterItem*)rosterItem;
- (void)XMPP_updateRosterItem: (XMPPRosterItem*)rosterItem;
- (void)XMPP_deleteRosterItem: (XMPPRosterItem*)rosterItem;
- (OFDictionary*)rosterItems;
- (void)addRosterItem: (XMPPRosterItem*)rosterItem;
- (void)updateRosterItem: (XMPPRosterItem*)rosterItem;
- (void)deleteRosterItem: (XMPPRosterItem*)rosterItem;
@end

Modified src/XMPPRoster.m from [401105b7c9] to [4eed8628a8].

29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
@implementation XMPPRoster
- initWithConnection: (XMPPConnection*)conn
{
	self = [super init];

	@try {
		connection = [conn retain];
		groups = [[OFMutableDictionary alloc] init];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}

- (void)dealloc
{
	[connection release];

	[super dealloc];
}

- (void)XMPP_addRosterItem: (XMPPRosterItem*)rosterItem
{
	if ([[rosterItem groups] count] > 0) {
		OFEnumerator *enumerator;
		OFString *group;

		enumerator = [[rosterItem groups] objectEnumerator];
		while ((group = [enumerator nextObject]) != nil) {
			OFMutableArray *rosterGroup =
			    [groups objectForKey: group];

			if (rosterGroup == nil) {
				rosterGroup = [OFMutableArray array];
				[groups setObject: rosterGroup
					   forKey: group];
			}

			[rosterGroup addObject: rosterItem];
		}
	} else {
		OFMutableArray *rosterGroup = [groups objectForKey: @""];

		if (rosterGroup == nil) {
			rosterGroup = [OFMutableArray array];
			[groups setObject: rosterGroup
				   forKey: @""];
		}

		[rosterGroup addObject: rosterItem];
	}
}

- (OFArray*)groups
{
	OFMutableArray *ret = [OFMutableArray array];
	OFEnumerator *enumerator;
	OFString *group;

	enumerator = [groups keyEnumerator];
	while ((group = [enumerator nextObject]) != nil)
		[ret addObject: group];

	ret->isa = [OFArray class];
	return ret;
}

- (OFArray*)rosterItemsInGroup: (OFString*)group
{
	if (group == nil)
		group = @"";

	return [[[groups objectForKey: group] copy] autorelease];
}

- (void)addRosterItem: (XMPPRosterItem*)rosterItem
{
	[self updateRosterItem: rosterItem];
}








|

















<
<
<
|
<
<
<
<
|
<
<
<
<
|
|
<
<
<
<
|
<
<
|
|
|

<
<
<
|
<

<
<
<
|
<
<
<
|
<
<
|
<
|

<
<
<
|







29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53



54




55




56
57




58


59
60
61
62



63

64



65



66


67

68
69



70
71
72
73
74
75
76
77
@implementation XMPPRoster
- initWithConnection: (XMPPConnection*)conn
{
	self = [super init];

	@try {
		connection = [conn retain];
		rosterItems = [[OFMutableDictionary alloc] init];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}

- (void)dealloc
{
	[connection release];

	[super dealloc];
}

- (void)XMPP_addRosterItem: (XMPPRosterItem*)rosterItem
{



	return [self XMPP_updateRosterItem: rosterItem];




}





- (void)XMPP_updateRosterItem: (XMPPRosterItem*)rosterItem




{


	[rosterItems setObject: rosterItem
			forKey: [[rosterItem JID] bareJID]];
}




- (void)XMPP_deleteRosterItem: (XMPPRosterItem*)rosterItem

{



	[rosterItems removeObjectForKey: [[rosterItem JID] bareJID]];



}




- (OFDictionary*)rosterItems
{



	return [[rosterItems copy] autorelease];
}

- (void)addRosterItem: (XMPPRosterItem*)rosterItem
{
	[self updateRosterItem: rosterItem];
}

Modified tests/test.m from [d26de2a21f] to [af27a5ba19].

122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143

	[conn requestRoster];
}

- (void)connectionDidReceiveRoster :(XMPPConnection*)conn
{
	XMPPPresence *pres;
	OFEnumerator *enumerator;
	OFString *group;

	of_log(@"Got roster! Groups: %@", [[conn roster] groups]);
	enumerator = [[[conn roster] groups] objectEnumerator];
	while ((group = [enumerator nextObject]) != nil)
		of_log(@"Group %@: %@", group,
		    [[conn roster] rosterItemsInGroup: group]);

	pres = [XMPPPresence presence];
	[pres addPriority: 10];
	[pres addStatus: @"ObjXMPP test is working!"];

	[conn sendStanza: pres];
}







<
<

<
<
<
<
|







122
123
124
125
126
127
128


129




130
131
132
133
134
135
136
137

	[conn requestRoster];
}

- (void)connectionDidReceiveRoster :(XMPPConnection*)conn
{
	XMPPPresence *pres;







	of_log(@"Got roster: %@", [[conn roster] rosterItems]);

	pres = [XMPPPresence presence];
	[pres addPriority: 10];
	[pres addStatus: @"ObjXMPP test is working!"];

	[conn sendStanza: pres];
}