ObjXMPP  Check-in [15caf24f36]

Overview
Comment:Fix a few bugs in roster versioning.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 15caf24f3631ac0a6fe2858826f0ea244f76994ff0bec2b2a58b7ba5ba4646a2
User & Date: js on 2012-02-06 15:33:50
Other Links: manifest | tags
Context
2012-02-06
15:53
Don't import old roster if we got a complete roster by the server. check-in: 57587da1f3 user: js tags: trunk
15:33
Fix a few bugs in roster versioning. check-in: 15caf24f36 user: js tags: trunk
15:17
Implement roster versioning.
Still needs some testing.
check-in: e6237b123a user: js tags: trunk
Changes

Modified src/XMPPJSONFileStorage.m from [35e51b270b] to [2ab1b12654].

35
36
37
38
39
40
41
42


43
44
45
46
47
48
49
35
36
37
38
39
40
41

42
43
44
45
46
47
48
49
50







-
+
+







#import "XMPPJSONFileStorage.h"

@implementation XMPPJSONFileStorage
- init
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException exceptionWithClass: c];
	@throw [OFNotImplementedException exceptionWithClass: c
						    selector: _cmd];
}

- initWithFile: (OFString*)file_
{
	self = [super init];

	@try {
99
100
101
102
103
104
105

106
107




108
109
110
111
112
113
114
100
101
102
103
104
105
106
107


108
109
110
111
112
113
114
115
116
117
118







+
-
-
+
+
+
+







			[iter setObject: iter2
				 forKey: component];
		}

		iter = iter2;
	}

	if (object != nil)
	[iter setObject: object
		 forKey: [pathComponents lastObject]];
		[iter setObject: object
			 forKey: [pathComponents lastObject]];
	else
		[iter removeObjectForKey: [pathComponents lastObject]];
}

- (id)XMPP_objectForPath: (OFString*)path
{
	OFArray *pathComponents = [path componentsSeparatedByString: @"."];
	OFEnumerator *enumerator = [pathComponents objectEnumerator];
	OFString *component;

Modified src/XMPPRoster.m from [ffdcace8e3] to [247e0e304c].

129
130
131
132
133
134
135

136
137
138
139
140
141
142
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143







+







	}

	if ([connection supportsRosterVersioning]) {
		OFString *ver =
		    [[rosterElement attributeForName: @"ver"] stringValue];
		[dataStorage setStringValue: ver
				    forPath: @"roster.ver"];
		[dataStorage save];
	}

	[delegates broadcastSelector: @selector(
					  roster:didReceiveRosterItem:)
			  withObject: self
			  withObject: rosterItem];

224
225
226
227
228
229
230



231
232
233
234
235
236
237
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241







+
+
+








- (void)XMPP_updateRosterItem: (XMPPRosterItem*)rosterItem
{
	if ([connection supportsRosterVersioning]) {
		OFMutableDictionary *items = [[[dataStorage dictionaryForPath:
		    @"roster.items"] mutableCopy] autorelease];

		if (items == nil)
			items = [OFMutableDictionary dictionary];

		if (![[rosterItem subscription] isEqual: @"remove"]) {
			OFMutableDictionary *item = [OFMutableDictionary
			    dictionaryWithKeysAndObjects:
			    @"JID", [[rosterItem JID] bareJID],
			    @"subscription", [rosterItem subscription],
			    nil];

338
339
340
341
342
343
344

345
346
347
348
349
350
351
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356







+







	}

	if ([connection supportsRosterVersioning]) {
		OFString *ver =
		    [[rosterElement attributeForName: @"ver"] stringValue];
		[dataStorage setStringValue: ver
				    forPath: @"roster.ver"];
		[dataStorage save];
	}

	[delegates broadcastSelector: @selector(rosterWasReceived:)
			  withObject: self];
}
@end

Modified tests/test.m from [e993b8ccf6] to [7a00751abf].

28
29
30
31
32
33
34

35
36
37
38
39
40
41
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42







+







#import "XMPPConnection.h"
#import "XMPPJID.h"
#import "XMPPStanza.h"
#import "XMPPIQ.h"
#import "XMPPMessage.h"
#import "XMPPPresence.h"
#import "XMPPRoster.h"
#import "XMPPJSONFileStorage.h"

@interface AppDelegate: OFObject
#ifdef OF_HAVE_OPTIONAL_PROTOCOLS
    <OFApplicationDelegate, XMPPConnectionDelegate, XMPPRosterDelegate>
#endif
{
	XMPPConnection *conn;
88
89
90
91
92
93
94

95
96

97



98


99
100
101
102
103
104
105
89
90
91
92
93
94
95
96
97

98
99
100
101
102

103
104
105
106
107
108
109
110
111







+

-
+

+
+
+
-
+
+







		       stringValue: @"42"];
	XMPPStanza *stanza = [XMPPStanza stanzaWithElement: elem];
	assert([[elem XMLString] isEqual: [stanza XMLString]]);
	assert(([[OFString stringWithFormat: @"%@, %@, %@, %@",
	    [[stanza from] fullJID], [[stanza to] fullJID], [stanza type],
	    [stanza ID]] isEqual: @"bob@localhost, alice@localhost, get, 42"]));


	conn = [[XMPPConnection alloc] init];
	roster = [[XMPPRoster alloc] initWithConnection: conn];
	[conn addDelegate: self];

	XMPPJSONFileStorage *storage =
	    [[XMPPJSONFileStorage alloc] initWithFile: @"storage.json"];
	[conn setDataStorage: storage];
	[conn addDelegate: self];

	roster = [[XMPPRoster alloc] initWithConnection: conn];
	[roster addDelegate: self];

	if ([arguments count] != 3) {
		of_log(@"Invalid count of command line arguments!");
		[OFApplication terminateWithStatus: 1];
	}