StropheCappuccino API 1.0.0
/tmp/tempDoc.doc/TNStropheIMClient.j
Go to the documentation of this file.
00001 /*
00002  * TNStropheIMClient.j
00003  *
00004  * Copyright (C) 2010  Ben Langfeld <ben@langfeld.me>
00005  *
00006  * This library is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Lesser General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 3.0 of the License, or (at your option) any later version.
00010  *
00011  * This library is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Lesser General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public
00017  * License along with this library; if not, write to the Free Software
00018  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00019  */
00020 
00021 
00022 
00023 
00024 @implementation TNStropheIMClient : TNStropheClient
00025 {
00026     TNStropheRoster _roster;
00027 }
00028 
00029 #pragma mark -
00030 #pragma mark Class methods
00031 
00038 + (TNStropheIMClient)IMClientWithService:(CPString)aService
00039 {
00040     return [[TNStropheIMClient alloc] initWithService:aService];
00041 }
00042 
00050 + (TNStropheIMClient)IMClientWithService:(CPString)aService rosterClass:(id)aRosterClass
00051 {
00052     return [[TNStropheIMClient alloc] initWithService:aService rosterClass:aRosterClass];
00053 }
00054 
00063 + (TNStropheIMClient)IMClientWithService:(CPString)aService JID:(TNStropheJID)aJID password:(CPString)aPassword
00064 {
00065     return [[TNStropheIMClient alloc] initWithService:aService JID:aJID password:aPassword];
00066 }
00067 
00077 + (TNStropheIMClient)IMClientWithService:(CPString)aService JID:(TNStropheJID)aJID password:(CPString)aPassword rosterClass:(id)aRosterClass
00078 {
00079     return [[TNStropheIMClient alloc] initWithService:aService JID:aJID password:aPassword rosterClass:aRosterClass];
00080 }
00081 
00082 
00083 #pragma mark -
00084 #pragma mark Initialization
00085 
00091 - (id)initWithService:(CPString)aService rosterClass:(id)aRosterClass
00092 {
00093     if (self = [super initWithService:aService])
00094     {
00095         if (!aRosterClass)
00096             aRosterClass = TNStropheRoster;
00097         _roster = [aRosterClass rosterWithConnection:_connection];
00098     }
00099 
00100     return self;
00101 }
00102 
00110 - (id)initWithService:(CPString)aService JID:(TNStropheJID)aJID password:(CPString)aPassword rosterClass:(id)aRosterClass
00111 {
00112     if (self = [self initWithService:aService rosterClass:aRosterClass])
00113     {
00114         _JID        = aJID;
00115         _password   = aPassword;
00116 
00117         [[CPNotificationCenter defaultCenter] addObserver:self selector:@selector(_didReceiveRoster:) name:TNStropheRosterRetrievedNotification object:nil];
00118     }
00119 
00120     return self;
00121 }
00122 
00123 #pragma mark -
00124 #pragma mark Notification handler
00125 
00130 - (void)_didReceiveRoster:(CPNotification)aNotification
00131 {
00132     [self _sendInitialPresence];
00133     [super onStropheConnected:_connection];
00134 }
00135 
00136 #pragma mark -
00137 #pragma mark Connection
00138 
00139 
00140 - (void)onStropheConnected:(TNStropheConnection)aConnection
00141 {
00142     [_roster getSubGroupDelimiter];
00143 }
00144 
00145 - (void)onStropheConnectFail:(TNStropheConnection)aConnection
00146 {
00147     [_roster clear];
00148     [super onStropheConnectFail:aConnection];
00149 }
00150 
00151 - (void)onStropheDisconnected:(TNStropheConnection)aConnection
00152 {
00153     [_roster clear];
00154     [super onStropheDisconnected:aConnection];
00155 }
00156 
00157 - (void)onStropheError:(TNStropheConnection)aConnection
00158 {
00159     [_roster clear];
00160     [super onStropheError:aConnection];
00161 }
00162 
00163 - (id)initWithCoder:(CPCoder)aCoder
00164 {
00165     self = [super initWithCoder:aCoder];
00166 
00167     if (self)
00168     {
00169         _roster = [aCoder decodeObjectForKey:@"_roster"];
00170     }
00171 
00172     return self;
00173 }
00174 
00175 - (void)encodeWithCoder:(CPCoder)aCoder
00176 {
00177     [super encodeWithCoder:aCoder];
00178     [aCoder encodeObject:_roster forKey:@"_roster"];
00179 }
00180 
00181 @end
00182 
00183 @implementation TNStropheIMClient (CPSynthesizedAccessors)
00184 
00188 - (TNStropheRoster)roster
00189 {
00190     return _roster;
00191 }
00192 
00193 @end
 All Classes Namespaces Files Functions Variables