Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
193 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
xcuserdata |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
ISC License (ISC) | ||
Copyright (c) 2016, Keyvan Fatehi | ||
|
||
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# ichat2json | ||
|
||
Reads an .ichat binary plist file and writes newline-separated JSON to STDOUT | ||
|
||
## Special Thanks | ||
|
||
* https://github.com/jmah/iChat-Image-Indexer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// | ||
// InstantMessage.h | ||
// ichat2json | ||
// | ||
// Created by Keyvan Fatehi on 12/9/16. | ||
// Copyright © 2016 Keyvan Fatehi. All rights reserved. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
#import "Sender.h" | ||
|
||
@interface InstantMessage : NSObject <NSCoding /* Decoding only */> | ||
|
||
@property (readonly, copy) NSDate *date; | ||
@property (readonly, copy) NSAttributedString *message; | ||
@property (readonly, copy) Sender *sender; | ||
- (NSString *) toJSONString; | ||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// | ||
// InstantMessage.m | ||
// ichat2json | ||
// | ||
// Created by Keyvan Fatehi on 12/9/16. | ||
// Copyright © 2016 Keyvan Fatehi. All rights reserved. | ||
|
||
#import "InstantMessage.h" | ||
|
||
@implementation InstantMessage | ||
- (id)initWithCoder:(NSCoder *)decoder; | ||
{ | ||
if (!(self = [super init])) | ||
return nil; | ||
_sender = [decoder decodeObjectForKey:@"Sender"]; | ||
_date = [decoder decodeObjectForKey:@"Time"]; | ||
_message = [decoder decodeObjectForKey:@"MessageText"]; | ||
|
||
return self; | ||
} | ||
|
||
- (void)encodeWithCoder:(NSCoder *)encoder; | ||
{ NSAssert1(NO, @"%@ does not allow encoding.", [self class]); } | ||
|
||
- (NSString *) toJSONString; | ||
{ | ||
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init]; | ||
[dateFormat setDateFormat:@"yyyy-MM-dd'T'HH:mm:ss.SSS"]; | ||
NSString *dateStr = [dateFormat stringFromDate:_date]; | ||
NSString *msg = [_message string]; | ||
NSString *senderName = [_sender accountName]; | ||
NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:senderName, @"sender", msg, @"message", dateStr, @"date", nil]; | ||
NSError *error; | ||
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:dict options:NSJSONWritingPrettyPrinted error:&error]; | ||
NSString *jsonString; | ||
if (! jsonData) { | ||
NSLog(@"Got an error: %@", error); | ||
} else { | ||
jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding]; | ||
} | ||
return jsonString; | ||
} | ||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// | ||
// Sender.h | ||
// ichat2json | ||
// | ||
// Created by Keyvan Fatehi on 12/9/16. | ||
// Copyright © 2016 Keyvan Fatehi. All rights reserved. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
@interface Sender : NSObject <NSCoding /* Decoding only */> | ||
|
||
@property (readonly, copy) NSString *accountName; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// | ||
// Sender.m | ||
// ichat2json | ||
// | ||
// Created by Keyvan Fatehi on 12/9/16. | ||
// Copyright © 2016 Keyvan Fatehi. All rights reserved. | ||
// | ||
|
||
#import "Sender.h" | ||
|
||
@implementation Sender | ||
|
||
@synthesize accountName = _accountName; | ||
|
||
- (id)initWithCoder:(NSCoder *)decoder; | ||
{ | ||
if (!(self = [super init])) | ||
return nil; | ||
_accountName = [decoder decodeObjectForKey:@"ID"]; | ||
return self; | ||
} | ||
|
||
- (void)encodeWithCoder:(NSCoder *)encoder; | ||
{ NSAssert1(NO, @"%@ does not allow encoding.", [self class]); } | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// | ||
// StubCoder.h | ||
// ichat2json | ||
// | ||
// Created by Keyvan Fatehi on 12/9/16. | ||
// Copyright © 2016 Keyvan Fatehi. All rights reserved. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
@interface StubCoder : NSObject | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// | ||
// StubCoder.m | ||
// ichat2json | ||
// | ||
// Created by Keyvan Fatehi on 12/9/16. | ||
// Copyright © 2016 Keyvan Fatehi. All rights reserved. | ||
// | ||
|
||
#import "StubCoder.h" | ||
|
||
@implementation StubCoder | ||
- (id)initWithCoder:(NSCoder *)decoder; | ||
{ | ||
if (!(self = [super init])) | ||
return nil; | ||
|
||
return self; | ||
} | ||
|
||
- (void)encodeWithCoder:(NSCoder *)encoder; | ||
{ NSAssert1(NO, @"%@ does not allow encoding.", [self class]); } | ||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters