Skip to content
Browse files

Allow TNStropheClient to be instructed to create roster using an alte…

…rnative class

* Should be a subclass of TNStropheRoster
  • Loading branch information...
1 parent 46fb922 commit 71d8d48a2c1059626b703ee487913753e6442e23 @benlangfeld committed Jan 16, 2011
Showing with 52 additions and 2 deletions.
  1. +52 −2 TNStropheClient.j
View
54 TNStropheClient.j
@@ -67,6 +67,18 @@
/*! instantiate a TNStropheClient object
@param aService a url of a bosh service (MUST be complete url with http://)
+ @param aRosterClass the specific roster class to use (optional, defaults to TNStropheRoster)
+
+ @return a valid TNStropheClient
+*/
++ (TNStropheClient)clientWithService:(CPString)aService rosterClass:(id)aRosterClass
+{
+ return [[TNStropheClient alloc] initWithService:aService rosterClass:aRosterClass];
+}
+
+/*! instantiate a TNStropheClient object
+
+ @param aService a url of a bosh service (MUST be complete url with http://)
@param aJID a JID to connect to the XMPP server
@param aPassword the password associated to the JID
@@ -77,6 +89,20 @@
return [[TNStropheClient alloc] initWithService:aService JID:aJID password:aPassword];
}
+/*! instantiate a TNStropheClient object
+
+ @param aService a url of a bosh service (MUST be complete url with http://)
+ @param aJID a JID to connect to the XMPP server
+ @param aPassword the password associated to the JID
+ @param aRosterClass the specific roster class to use (optional, defaults to TNStropheRoster)
+
+ @return a valid TNStropheClient
+*/
++ (TNStropheClient)clientWithService:(CPString)aService JID:(TNStropheJID)aJID password:(CPString)aPassword rosterClass:(id)aRosterClass
+{
+ return [[TNStropheClient alloc] initWithService:aService JID:aJID password:aPassword rosterClass:aRosterClass];
+}
+
#pragma mark -
#pragma mark Initialization
@@ -87,10 +113,22 @@
*/
- (id)initWithService:(CPString)aService
{
+ return [self initWithService:aService rosterClass:nil];
+}
+
+/*! initialize the TNStropheClient
+
+ @param aService a url of a bosh service (MUST be complete url with http://)
+ @param aRosterClass the specific roster class to use (optional, defaults to TNStropheRoster)
+*/
+- (id)initWithService:(CPString)aService rosterClass:(id)aRosterClass
+{
if (self = [super init])
{
_connection = [TNStropheConnection connectionWithService:aService andDelegate:self];
- _roster = [TNStropheRoster rosterWithConnection:_connection];
+ if (!aRosterClass)
+ aRosterClass = TNStropheRoster;
+ _roster = [aRosterClass rosterWithConnection:_connection];
_userPresenceShow = TNStropheContactStatusOffline;
_userPresenceStatus = @"";
_clientNode = @"http://cappuccino.org";
@@ -111,7 +149,19 @@
*/
- (id)initWithService:(CPString)aService JID:(TNStropheJID)aJID password:(CPString)aPassword
{
- if (self = [self initWithService:aService])
+ return [self initWithService:aService JID:aJID password:aPassword rosterClass:nil];
+}
+
+/*! initialize the TNStropheClient
+
+ @param aService a url of a bosh service (MUST be complete url with http://)
+ @param aJID a JID to connect to the XMPP server
+ @param aPassword the password associated to the JID
+ @param aRosterClass the specific roster class to use (optional, defaults to TNStropheRoster)
+*/
+- (id)initWithService:(CPString)aService JID:(TNStropheJID)aJID password:(CPString)aPassword rosterClass:(id)aRosterClass
+{
+ if (self = [self initWithService:aService rosterClass:aRosterClass])
{
_JID = aJID;
_password = aPassword;

0 comments on commit 71d8d48

Please sign in to comment.
Something went wrong with that request. Please try again.