Permalink
Browse files

Use new CPImage with base64 encoding possibilities instead of TNBase6…

…4Image
  • Loading branch information...
primalmotion committed Jun 14, 2012
1 parent 6180754 commit d0fc1f44de28ec8d2a23e04f09f4372ba84e0630
Showing with 16 additions and 56 deletions.
  1. +6 −1 TNBase64Image.j
  2. +3 −4 TNStropheClient.j
  3. +7 −7 TNStropheContact.j
  4. +0 −44 Test/TNBase64ImageTest.j
View
@@ -22,6 +22,7 @@
/*! @ingroup strophecappuccino
+ @deperecated
this is a subclass of CPImage that allows to create a CPImage from a image
encoded in a base64 CPString.
*/
@@ -38,6 +39,8 @@
*/
+ (TNBase64Image)base64ImageWithContentType:(CPString)aContentType andData:(CPString)someBase64Data
{
+ CPLog.warn("DEPRECATED: TNBase64Image is deprecated. Please use new CPImage base64 encoding capabilities");
+
var img = [[TNBase64Image alloc] init];
[img setBase64EncodedData:someBase64Data];
@@ -50,6 +53,8 @@
+ (TNBase64Image)base64ImageWithContentType:(CPString)aContentType data:(CPString)someBase64Data delegate:(id)aDelegate
{
+ CPLog.warn("DEPRECATED: TNBase64Image is deprecated. Please use new CPImage base64 encoding capabilities");
+
var img = [[TNBase64Image alloc] init];
[img setBase64EncodedData:someBase64Data];
@@ -102,4 +107,4 @@
return dataURL.replace(/^data:image\/(png|jpg);base64,/, "");
}
-@end
+@end
View
@@ -377,7 +377,7 @@ TNStropheClientVCardReceivedNotification = @"TNStropheClientVCardReceived
var type = [[photo firstChildWithName:@"TYPE"] text],
binval = [[photo firstChildWithName:@"BINVAL"] text];
- _avatar = [TNBase64Image base64ImageWithContentType:type andData:binval];
+ _avatar = [[CPImage alloc] initWithData:[CPData dataWithBase64:binval]];
}
}
@@ -401,10 +401,9 @@ TNStropheClientVCardReceivedNotification = @"TNStropheClientVCardReceived
if (photo)
{
- var type = [[photo firstChildWithName:@"TYPE"] text],
- binval = [[photo firstChildWithName:@"BINVAL"] text];
+ var binval = [[photo firstChildWithName:@"BINVAL"] text];
- _avatar = [TNBase64Image base64ImageWithContentType:type andData:binval];
+ _avatar = [[CPImage alloc] initWithData:[CPData dataWithBase64:binval]];
}
_vCard = aVCard;
View
@@ -20,7 +20,6 @@
@import <Foundation/Foundation.j>
-@import "TNBase64Image.j"
@import "TNStropheConnection.j"
@import "TNStropheGroup.j"
@import "TNStropheJID.j"
@@ -76,7 +75,7 @@ var TNStropheContactImageOffline,
CPString _XMPPShow @accessors(property=XMPPShow);
CPString _XMPPStatus @accessors(property=XMPPStatus);
id _delegate @accessors(getter=delegate);
- TNBase64Image _avatar @accessors(property=avatar);
+ CPImage _avatar @accessors(property=avatar);
TNStropheConnection _connection @accessors(property=connection);
TNStropheJID _JID @accessors(property=JID);
@@ -385,7 +384,7 @@ var TNStropheContactImageOffline,
}
/*! executed on getVCard result. Will post TNStropheContactVCardReceivedNotification
- and send notifications. If vCard contains a PHOTO node, it will set the avatar TNBase64Image
+ and send notifications. If vCard contains a PHOTO node, it will set the avatar CPImage
property of the TNStropheContact
You should never have to use this method
@param aStanza the response TNStropheStanza
@@ -414,11 +413,12 @@ var TNStropheContactImageOffline,
if (photoNode = [aVCard firstChildWithName:@"PHOTO"])
{
- var contentType = [[photoNode firstChildWithName:@"TYPE"] text],
- data = [[photoNode firstChildWithName:@"BINVAL"] text];
+ var data = [[photoNode firstChildWithName:@"BINVAL"] text];
// the delegate will send the TNStropheContactVCardReceivedNotification when image will be ready
- _avatar = [TNBase64Image base64ImageWithContentType:contentType data:data delegate:self];
+ _avatar = [[CPImage alloc] initWithData:[CPData dataWithBase64:data]];
+ [_avatar setDelegate:self];
+
}
else
{
@@ -658,7 +658,7 @@ var TNStropheContactImageOffline,
/*! this method is called when the avatar image is ready.
@param anImage the image that sent the message
*/
-- (void)imageDidLoad:(TNBase64Image)anImage
+- (void)imageDidLoad:(CPImage)anImage
{
[anImage setDelegate:nil];
[[CPNotificationCenter defaultCenter] postNotificationName:TNStropheContactVCardReceivedNotification object:self];
View
@@ -1,44 +0,0 @@
-/*
- * TNBase64ImageTest.j
- *
- * Copyright (C) 2010 Antoine Mercadal <antoine.mercadal@inframonde.eu>
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-
-@import <Foundation/Foundation.j>
-@import <AppKit/AppKit.j>
-
-@import "../Resources/Strophe/strophe.js"
-@import "../Resources/Strophe/sha1.js"
-@import "../TNBase64Image.j"
-
-
-@implementation TNBase64ImageTest : OJTestCase
-{
-}
-
-- (void)setUp
-{
-}
-
-- (void)testInit
-{
-}
-
-- (void)tearDown
-{
-}
-
-@end

0 comments on commit d0fc1f4

Please sign in to comment.