Style improvements.
This commit is contained in:
parent
f42623800d
commit
da76528178
7 changed files with 38 additions and 37 deletions
|
@ -25,7 +25,7 @@
|
||||||
@class XMPPIQ;
|
@class XMPPIQ;
|
||||||
|
|
||||||
#ifdef OF_HAVE_BLOCKS
|
#ifdef OF_HAVE_BLOCKS
|
||||||
typedef void(^xmpp_callback_block)(XMPPIQ*);
|
typedef void(^xmpp_callback_block_t)(XMPPIQ*);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@interface XMPPCallback: OFObject
|
@interface XMPPCallback: OFObject
|
||||||
|
@ -33,10 +33,12 @@ typedef void(^xmpp_callback_block)(XMPPIQ*);
|
||||||
id object;
|
id object;
|
||||||
SEL selector;
|
SEL selector;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef OF_HAVE_BLOCKS
|
#ifdef OF_HAVE_BLOCKS
|
||||||
+ callbackWithCallbackBlock: (xmpp_callback_block)callback;
|
+ callbackWithCallbackBlock: (xmpp_callback_block_t)callback;
|
||||||
- initWithCallbackBlock: (xmpp_callback_block)callback;
|
- initWithCallbackBlock: (xmpp_callback_block_t)callback;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
+ callbackWithCallbackObject: (id)object
|
+ callbackWithCallbackObject: (id)object
|
||||||
selector: (SEL)selector;
|
selector: (SEL)selector;
|
||||||
- initWithCallbackObject: (id)object
|
- initWithCallbackObject: (id)object
|
||||||
|
|
|
@ -28,12 +28,12 @@
|
||||||
|
|
||||||
@implementation XMPPCallback
|
@implementation XMPPCallback
|
||||||
#ifdef OF_HAVE_BLOCKS
|
#ifdef OF_HAVE_BLOCKS
|
||||||
+ callbackWithCallbackBlock: (xmpp_callback_block)callback
|
+ callbackWithCallbackBlock: (xmpp_callback_block_t)callback
|
||||||
{
|
{
|
||||||
return [[[self alloc] initWithCallbackBlock: callback] autorelease];
|
return [[[self alloc] initWithCallbackBlock: callback] autorelease];
|
||||||
}
|
}
|
||||||
|
|
||||||
- initWithCallbackBlock: (xmpp_callback_block)callback
|
- initWithCallbackBlock: (xmpp_callback_block_t)callback
|
||||||
{
|
{
|
||||||
self = [super init];
|
self = [super init];
|
||||||
|
|
||||||
|
@ -55,8 +55,7 @@
|
||||||
{
|
{
|
||||||
self = [super init];
|
self = [super init];
|
||||||
|
|
||||||
// TODO: Retain or follow delegate paradigm?
|
object = object_;
|
||||||
object = [object_ retain];
|
|
||||||
selector = selector_;
|
selector = selector_;
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
|
@ -64,8 +63,6 @@
|
||||||
|
|
||||||
- (void)dealloc
|
- (void)dealloc
|
||||||
{
|
{
|
||||||
[object release];
|
|
||||||
|
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,7 +70,7 @@
|
||||||
{
|
{
|
||||||
#ifdef OF_HAVE_BLOCKS
|
#ifdef OF_HAVE_BLOCKS
|
||||||
if ([object isKindOfClass: [OFBlock class]])
|
if ([object isKindOfClass: [OFBlock class]])
|
||||||
((xmpp_callback_block)object)(iq);
|
((xmpp_callback_block_t)object)(iq);
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
[object performSelector: selector
|
[object performSelector: selector
|
||||||
|
|
|
@ -384,7 +384,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)sendIQ: (XMPPIQ*)iq
|
- (void)sendIQ: (XMPPIQ*)iq
|
||||||
withCallbackObject: (id)object
|
withCallbackObject: (id)object
|
||||||
selector: (SEL)selector
|
selector: (SEL)selector
|
||||||
{
|
{
|
||||||
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
|
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
|
||||||
|
@ -405,7 +405,7 @@ withCallbackObject: (id)object
|
||||||
|
|
||||||
#ifdef OF_HAVE_BLOCKS
|
#ifdef OF_HAVE_BLOCKS
|
||||||
- (void)sendIQ: (XMPPIQ*)iq
|
- (void)sendIQ: (XMPPIQ*)iq
|
||||||
withCallbackBlock: (xmpp_callback_block)callback;
|
withCallbackBlock: (xmpp_callback_block_t)callback;
|
||||||
{
|
{
|
||||||
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
|
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
|
||||||
@try {
|
@try {
|
||||||
|
|
|
@ -42,7 +42,7 @@
|
||||||
|
|
||||||
- (OFDataArray*)initialMessage
|
- (OFDataArray*)initialMessage
|
||||||
{
|
{
|
||||||
OFDataArray *message = [OFDataArray dataArrayWithItemSize: 1];
|
OFDataArray *message = [OFDataArray dataArray];
|
||||||
|
|
||||||
/* authzid */
|
/* authzid */
|
||||||
if (authzid)
|
if (authzid)
|
||||||
|
|
|
@ -46,7 +46,7 @@
|
||||||
|
|
||||||
- (OFDataArray*)initialMessage
|
- (OFDataArray*)initialMessage
|
||||||
{
|
{
|
||||||
OFDataArray *message = [OFDataArray dataArrayWithItemSize: 1];
|
OFDataArray *message = [OFDataArray dataArray];
|
||||||
|
|
||||||
/* authzid */
|
/* authzid */
|
||||||
if (authzid)
|
if (authzid)
|
||||||
|
|
|
@ -81,6 +81,8 @@
|
||||||
{
|
{
|
||||||
if (type == nil)
|
if (type == nil)
|
||||||
return @"available";
|
return @"available";
|
||||||
|
|
||||||
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)addShow: (OFString*)show
|
- (void)addShow: (OFString*)show
|
||||||
|
|
|
@ -145,7 +145,7 @@
|
||||||
|
|
||||||
- (OFDataArray*)initialMessage
|
- (OFDataArray*)initialMessage
|
||||||
{
|
{
|
||||||
OFDataArray *ret = [OFDataArray dataArrayWithItemSize: 1];
|
OFDataArray *ret = [OFDataArray dataArray];
|
||||||
|
|
||||||
/* New authentication attempt, reset status */
|
/* New authentication attempt, reset status */
|
||||||
[cNonce release];
|
[cNonce release];
|
||||||
|
@ -215,8 +215,8 @@
|
||||||
} got = 0;
|
} got = 0;
|
||||||
|
|
||||||
hash = [[[hashType alloc] init] autorelease];
|
hash = [[[hashType alloc] init] autorelease];
|
||||||
ret = [OFDataArray dataArrayWithItemSize: 1];
|
ret = [OFDataArray dataArray];
|
||||||
authMessage = [OFDataArray dataArrayWithItemSize: 1];
|
authMessage = [OFDataArray dataArray];
|
||||||
|
|
||||||
OFString *chal = [OFString stringWithUTF8String: [data cArray]
|
OFString *chal = [OFString stringWithUTF8String: [data cArray]
|
||||||
length: [data count] *
|
length: [data count] *
|
||||||
|
@ -252,7 +252,7 @@
|
||||||
@throw [OFInvalidServerReplyException exceptionWithClass: isa];
|
@throw [OFInvalidServerReplyException exceptionWithClass: isa];
|
||||||
|
|
||||||
// Add c=<base64(GS2Header+channelBindingData)>
|
// Add c=<base64(GS2Header+channelBindingData)>
|
||||||
tmpArray = [OFDataArray dataArrayWithItemSize: 1];
|
tmpArray = [OFDataArray dataArray];
|
||||||
[tmpArray addNItems: [GS2Header UTF8StringLength]
|
[tmpArray addNItems: [GS2Header UTF8StringLength]
|
||||||
fromCArray: [GS2Header UTF8String]];
|
fromCArray: [GS2Header UTF8String]];
|
||||||
if (plusAvailable && [connection encrypted]) {
|
if (plusAvailable && [connection encrypted]) {
|
||||||
|
@ -278,7 +278,7 @@
|
||||||
* IETF RFC 5802:
|
* IETF RFC 5802:
|
||||||
* SaltedPassword := Hi(Normalize(password), salt, i)
|
* SaltedPassword := Hi(Normalize(password), salt, i)
|
||||||
*/
|
*/
|
||||||
tmpArray = [OFDataArray dataArrayWithItemSize: 1];
|
tmpArray = [OFDataArray dataArray];
|
||||||
[tmpArray addNItems: [password UTF8StringLength]
|
[tmpArray addNItems: [password UTF8StringLength]
|
||||||
fromCArray: [password UTF8String]];
|
fromCArray: [password UTF8String]];
|
||||||
|
|
||||||
|
@ -305,7 +305,7 @@
|
||||||
* IETF RFC 5802:
|
* IETF RFC 5802:
|
||||||
* ClientKey := HMAC(SaltedPassword, "Client Key")
|
* ClientKey := HMAC(SaltedPassword, "Client Key")
|
||||||
*/
|
*/
|
||||||
tmpArray = [OFDataArray dataArrayWithItemSize: 1];
|
tmpArray = [OFDataArray dataArray];
|
||||||
[tmpArray addNItems: 10
|
[tmpArray addNItems: 10
|
||||||
fromCArray: "Client Key"];
|
fromCArray: "Client Key"];
|
||||||
clientKey = [self XMPP_HMACWithKey: saltedPassword
|
clientKey = [self XMPP_HMACWithKey: saltedPassword
|
||||||
|
@ -317,7 +317,7 @@
|
||||||
*/
|
*/
|
||||||
[hash updateWithBuffer: (void*) clientKey
|
[hash updateWithBuffer: (void*) clientKey
|
||||||
length: [hashType digestSize]];
|
length: [hashType digestSize]];
|
||||||
tmpArray = [OFDataArray dataArrayWithItemSize: 1];
|
tmpArray = [OFDataArray dataArray];
|
||||||
[tmpArray addNItems: [hashType digestSize]
|
[tmpArray addNItems: [hashType digestSize]
|
||||||
fromCArray: [hash digest]];
|
fromCArray: [hash digest]];
|
||||||
|
|
||||||
|
@ -332,7 +332,7 @@
|
||||||
* IETF RFC 5802:
|
* IETF RFC 5802:
|
||||||
* ServerKey := HMAC(SaltedPassword, "Server Key")
|
* ServerKey := HMAC(SaltedPassword, "Server Key")
|
||||||
*/
|
*/
|
||||||
tmpArray = [OFDataArray dataArrayWithItemSize: 1];
|
tmpArray = [OFDataArray dataArray];
|
||||||
[tmpArray addNItems: 10
|
[tmpArray addNItems: 10
|
||||||
fromCArray: "Server Key"];
|
fromCArray: "Server Key"];
|
||||||
serverKey = [self XMPP_HMACWithKey: saltedPassword
|
serverKey = [self XMPP_HMACWithKey: saltedPassword
|
||||||
|
@ -342,10 +342,10 @@
|
||||||
* IETF RFC 5802:
|
* IETF RFC 5802:
|
||||||
* ServerSignature := HMAC(ServerKey, AuthMessage)
|
* ServerSignature := HMAC(ServerKey, AuthMessage)
|
||||||
*/
|
*/
|
||||||
tmpArray = [OFDataArray dataArrayWithItemSize: 1];
|
tmpArray = [OFDataArray dataArray];
|
||||||
[tmpArray addNItems: [hashType digestSize]
|
[tmpArray addNItems: [hashType digestSize]
|
||||||
fromCArray: serverKey];
|
fromCArray: serverKey];
|
||||||
serverSignature = [[OFDataArray alloc] initWithItemSize: 1];
|
serverSignature = [[OFDataArray alloc] init];
|
||||||
[serverSignature addNItems: [hashType digestSize]
|
[serverSignature addNItems: [hashType digestSize]
|
||||||
fromCArray: [self XMPP_HMACWithKey: tmpArray
|
fromCArray: [self XMPP_HMACWithKey: tmpArray
|
||||||
data: authMessage]];
|
data: authMessage]];
|
||||||
|
@ -354,7 +354,7 @@
|
||||||
* IETF RFC 5802:
|
* IETF RFC 5802:
|
||||||
* ClientProof := ClientKey XOR ClientSignature
|
* ClientProof := ClientKey XOR ClientSignature
|
||||||
*/
|
*/
|
||||||
tmpArray = [OFDataArray dataArrayWithItemSize: 1];
|
tmpArray = [OFDataArray dataArray];
|
||||||
for (i = 0; i < [hashType digestSize]; i++) {
|
for (i = 0; i < [hashType digestSize]; i++) {
|
||||||
uint8_t c = clientKey[i] ^ clientSignature[i];
|
uint8_t c = clientKey[i] ^ clientSignature[i];
|
||||||
[tmpArray addItem: &c];
|
[tmpArray addItem: &c];
|
||||||
|
@ -428,7 +428,7 @@
|
||||||
data: (OFDataArray*)data
|
data: (OFDataArray*)data
|
||||||
{
|
{
|
||||||
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
|
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
|
||||||
OFDataArray *k = [OFDataArray dataArrayWithItemSize: 1];
|
OFDataArray *k = [OFDataArray dataArray];
|
||||||
size_t i, kSize, blockSize = [hashType blockSize];
|
size_t i, kSize, blockSize = [hashType blockSize];
|
||||||
uint8_t *kI = NULL, *kO = NULL;
|
uint8_t *kI = NULL, *kO = NULL;
|
||||||
OFHash *hashI, *hashO;
|
OFHash *hashI, *hashO;
|
||||||
|
@ -505,7 +505,7 @@
|
||||||
result[j] ^= uOld[j];
|
result[j] ^= uOld[j];
|
||||||
|
|
||||||
for (j = 0; j < i - 1; j++) {
|
for (j = 0; j < i - 1; j++) {
|
||||||
tmp = [OFDataArray dataArrayWithItemSize: 1];
|
tmp = [OFDataArray dataArray];
|
||||||
[tmp addNItems: digestSize
|
[tmp addNItems: digestSize
|
||||||
fromCArray: uOld];
|
fromCArray: uOld];
|
||||||
|
|
||||||
|
@ -520,7 +520,7 @@
|
||||||
[pool releaseObjects];
|
[pool releaseObjects];
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = [OFDataArray dataArrayWithItemSize: 1];
|
ret = [OFDataArray dataArray];
|
||||||
[ret addNItems: digestSize
|
[ret addNItems: digestSize
|
||||||
fromCArray: result];
|
fromCArray: result];
|
||||||
} @finally {
|
} @finally {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue