disconiPhoneTaro Matsuzawa aka btm (@smellman)       at sumaben kanto #11
1981•
1988•
1989•
1991•   BL
1997•    •   Windows 95 OSR2    •   MMX Pentium 200Mhz
1999••   English Speaking Society (E.S.S.)•
2000•••   Mozilla Party JP 1.0   (   OSS    )•••               Linux••             E.S.S.
2001••••   Tokyo Linux Entertainment Community(TLEC)•   WEB
2002•••                  VB      (      )•   Mozilla Party 3.0 JP•••
2003••••   Mozilla Party JP 4.0••                  1000    40
2004•              (5   )•••    ••       ○
2005•   C Magazine 2005/10           2   Firefox      Piro                 C++•
2006•    ••
2007•   Software Design 2007/04 Firefox   (   )••     ○○•••
2008••   KBMJ•          Firefox 3 Hacks (   )••
2009•••   Software Design   Firefox      2009.11   2010.04•   OSS EC
2010•   iPhone           In App Purchase   2••            (   )
2011•       (   )•    •
•       iPhone•    •   iPhone    •            GUI    •    •
•    •          iPhone    •    •    •   IMAP    •
IMAP?
IMAP••   i.softbank.jp    •    •    •    •
•••   SSL•
•    •       ...    •    •   (         )
•   Pantomime    Mac OS X/GNUStep         LGPL2    •     2007    •    •                               ...    •    •
LGPL2 iPhone•   LGPL2                   (ex.    cocos2d-iphone   )    •••    •                          OK    •    •    • ...
Pantomime•   Objective-C             IMAP/POP/SMTP    •               Mac OS X      GNUStep••                  2007 / 2 / ...
1•    •   Mac OS X 10.2•    •   NSDebug•    •
2•   GNUStep    ••   SMTP    •                     (•   iOS    •         Apple    •         Apple
•    •   NSString cString    •   NSFileManager fileAttributesAtPath:traverseLink:•                      xcode•
NSFileManagerfileAttributesAtPath:traverseLink:
attributesOfItemAtPath:error:- attributes = [[NSFileManager defaultManager] fileAttributesAtPath: thePath traverseLink: NO]...
•   Pantomime       openssl    •   openssl-xcode         openssl                  iPhone        •   https://github.com/sjl...
•   libssl.a                openssl-xcode    •   https://github.com/smellman/openssl-xcode    ••   libssl.a   libcrypt.a
GNUStep•   GNUStep    •                #ifdef MACOSX              (iOS        )•   GNUStep    Mac OS X                    ...
-#ifdef MACOSX #include <Pantomime/CWMacOSXGlue.h>-#endif Mac OS X
-#ifdef MACOSX   #include <CoreFoundation/CFString.h>   #include <CoreFoundation/CFStringEncodingExt.h>  -#else  -#include...
iOS•   iOS    ••    •        •        •
NSHost•                          [[NSHost currentHost] name]    •        •   gethostname        •           NSString
gethostname+    char s[65];+    memset(s, 0, sizeof(s));+    gethostname(s, sizeof(s)-1);+    NSString *hostName = [NSStri...
NSCalendarDate•   iOS             Mac OS X   Legacy API•   Pantomime    •
NSCalendarDate•   NSCalendarDate    •   NSDate•   descriptionWithCalendarFormat    •   NSDateFormatter•    •   NSCalendar ...
-    NSCalendarDate *aCalendarDate;+     NSCalendar *calendar = [NSCalendar currentCalendar];+   NSDate *aCurrentDate = [[...
NSMapTable•   NSMapTable    typedef struct _NSMapTable NSMapTable;    •   Mac OS X 10.0   10.4•    •                      ...
•   NSCreateMapTable    •   NSCreateMapTable(NSObjectMapKeyCallBacks,        NSObjectMapValueCallBacks, 128);•            ...
NSMutableDictionary//- NSMapTable *_table;+ NSMutableDictionary *_table;//- _table = NSCreateMapTable(NSObjectMapKeyCallBa...
int•   NSCreateMapTable int    •   NSCreateMapTable(NSIntMapKeyCallBacks,        NSObjectMapValueCallBacks, 128);•   NSMut...
•                   Map•   Java                  (Generic)    •   Generic        •            •   std::map                ...
C++ iPhone•   iPhone        C++•            Objective-C•   Objective-C++    •   (    д)     (   д   )   (д    )•    •    •...
Objective-C++                           Map (1)    #ifndef _Pantomime_H_StdMapIntWrapper    #define _Pantomime_H_StdMapInt...
Objective-C++                                   Map (2)#import <Pantomime/StdMapIntWrapper.h>           - (void) removeVal...
//include+#include <Pantomime/StdMapIntWrapper.h>//-static NSMapTable *fd_to_cfsocket;+static StdMapIntWrapper *fd_to_cfso...
: Modified UTF-7•   Pantomime   Modified UTF-7    ••
- (NSString *) modifiedUTF7String{    NSString *str = self;    unichar c;    uint index = 0;    BOOL nowBase64 = NO;    NS...
•   Mac OS X•   Apple•    •   Objective-C++
URL•   Pantomime    •   http://www.collaboration-world.com/pantomime•   Pantomime iOS fork    •   https://github.com/smell...
(   )
スマートフォン勉強会@関東 #11 どう考えてもdisconなものをiPhoneに移植してみた
スマートフォン勉強会@関東 #11 どう考えてもdisconなものをiPhoneに移植してみた
Upcoming SlideShare
Loading in …5
×

スマートフォン勉強会@関東 #11 どう考えてもdisconなものをiPhoneに移植してみた

2,902 views

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
2,902
On SlideShare
0
From Embeds
0
Number of Embeds
228
Actions
Shares
0
Downloads
5
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

スマートフォン勉強会@関東 #11 どう考えてもdisconなものをiPhoneに移植してみた

  1. 1. disconiPhoneTaro Matsuzawa aka btm (@smellman) at sumaben kanto #11
  2. 2. 1981•
  3. 3. 1988•
  4. 4. 1989•
  5. 5. 1991• BL
  6. 6. 1997• • Windows 95 OSR2 • MMX Pentium 200Mhz
  7. 7. 1999•• English Speaking Society (E.S.S.)•
  8. 8. 2000••• Mozilla Party JP 1.0 ( OSS )••• Linux•• E.S.S.
  9. 9. 2001•••• Tokyo Linux Entertainment Community(TLEC)• WEB
  10. 10. 2002••• VB ( )• Mozilla Party 3.0 JP•••
  11. 11. 2003•••• Mozilla Party JP 4.0•• 1000 40
  12. 12. 2004• (5 )••• •• ○
  13. 13. 2005• C Magazine 2005/10 2 Firefox Piro C++•
  14. 14. 2006• ••
  15. 15. 2007• Software Design 2007/04 Firefox ( )•• ○○•••
  16. 16. 2008•• KBMJ• Firefox 3 Hacks ( )••
  17. 17. 2009••• Software Design Firefox 2009.11 2010.04• OSS EC
  18. 18. 2010• iPhone In App Purchase 2•• ( )
  19. 19. 2011• ( )• •
  20. 20. • iPhone• • iPhone • GUI • •
  21. 21. • • iPhone • • • IMAP •
  22. 22. IMAP?
  23. 23. IMAP•• i.softbank.jp • • • •
  24. 24. ••• SSL•
  25. 25. • • ... • • ( )
  26. 26. • Pantomime Mac OS X/GNUStep LGPL2 • 2007 • • ... • •
  27. 27. LGPL2 iPhone• LGPL2 (ex. cocos2d-iphone ) ••• • OK • • • ( • Σ( д lll)
  28. 28. Pantomime• Objective-C IMAP/POP/SMTP • Mac OS X GNUStep•• 2007 / 2 / 5 • discon (ry
  29. 29. 1• • Mac OS X 10.2• • NSDebug• •
  30. 30. 2• GNUStep •• SMTP • (• iOS • Apple • Apple
  31. 31. • • NSString cString • NSFileManager fileAttributesAtPath:traverseLink:• xcode•
  32. 32. NSFileManagerfileAttributesAtPath:traverseLink:
  33. 33. attributesOfItemAtPath:error:- attributes = [[NSFileManager defaultManager] fileAttributesAtPath: thePath traverseLink: NO];+ NSError *error = nil;+ attributes = [[NSFileManager defaultManager] attributesOfItemAtPath: thePath error: &error];
  34. 34. • Pantomime openssl • openssl-xcode openssl iPhone • https://github.com/sjlombardo/openssl-xcode• libcrypt.a libssl.a orz
  35. 35. • libssl.a openssl-xcode • https://github.com/smellman/openssl-xcode •• libssl.a libcrypt.a
  36. 36. GNUStep• GNUStep • #ifdef MACOSX (iOS )• GNUStep Mac OS X Mac OS X• OK (Search and Destroy)
  37. 37. -#ifdef MACOSX #include <Pantomime/CWMacOSXGlue.h>-#endif Mac OS X
  38. 38. -#ifdef MACOSX #include <CoreFoundation/CFString.h> #include <CoreFoundation/CFStringEncodingExt.h> -#else -#include <GNUstepBase/GSCategories.h> -#endifelse GNUStep
  39. 39. iOS• iOS •• • • •
  40. 40. NSHost• [[NSHost currentHost] name] • • gethostname • NSString
  41. 41. gethostname+ char s[65];+ memset(s, 0, sizeof(s));+ gethostname(s, sizeof(s)-1);+ NSString *hostName = [NSString stringWithCString:s encoding:NSUTF8StringEncoding]; aMailFile = [NSString stringWithFormat: @"%@:%@", [NSString stringWithFormat: @"%d.%d%d%d.%@", time(NULL), getpid(), rand(), [_cacheManager count],- [[NSHost currentHost] name]],+ hostName], ((id)theFlags ? (id)[theFlags maildirString] : (id)@"2,")];
  42. 42. NSCalendarDate• iOS Mac OS X Legacy API• Pantomime •
  43. 43. NSCalendarDate• NSCalendarDate • NSDate• descriptionWithCalendarFormat • NSDateFormatter• • NSCalendar NSDateCompoments• timeIntervalSince1970 • NSDate
  44. 44. - NSCalendarDate *aCalendarDate;+ NSCalendar *calendar = [NSCalendar currentCalendar];+ NSDate *aCurrentDate = [[NSData alloc] init]; int days;- // We get the days interval between our two dates aCalendarDate = [NSCalendarDate calendarDate]; w- [aCalendarDate years: NULL- months: NULL- days: &days- hours: NULL- minutes: NULL- seconds: NULL- sinceDate: aDate];-+ NSDateComponents *comps;+ NSUInteger flags = NSDayCalendarUnit;+ comps = [calendar components:flags+ fromDate:aDate+ toDate:aCurrentDate+ options:0];+ days = (int) [comps day];
  45. 45. NSMapTable• NSMapTable typedef struct _NSMapTable NSMapTable; • Mac OS X 10.0 10.4• • int• NSMapTable iOS
  46. 46. • NSCreateMapTable • NSCreateMapTable(NSObjectMapKeyCallBacks, NSObjectMapValueCallBacks, 128);• Map NSMutableDictionary
  47. 47. NSMutableDictionary//- NSMapTable *_table;+ NSMutableDictionary *_table;//- _table = NSCreateMapTable(NSObjectMapKeyCallBacks, NSObjectMapValueCallBacks, 128);+ _table = [[NSMutableDictionary alloc] initWithCapacity:128];//- NSMapInsert(_table, aUID, aDate);+ [_table setObject:aDate forKey:aUID];
  48. 48. int• NSCreateMapTable int • NSCreateMapTable(NSIntMapKeyCallBacks, NSObjectMapValueCallBacks, 128);• NSMutableDictionary • |← | (^o^ )
  49. 49. • Map• Java (Generic) • Generic • • std::map • C++ !!!!!!
  50. 50. C++ iPhone• iPhone C++• Objective-C• Objective-C++ • ( д) ( д ) (д )• • • C++ Objective-C++ ...
  51. 51. Objective-C++ Map (1) #ifndef _Pantomime_H_StdMapIntWrapper #define _Pantomime_H_StdMapIntWrapper #import <Foundation/Foundation.h> #ifdef __cplusplus #include <map> @interface StdMapIntWrapper : NSObject { @private std::map<int, int> *wrapper_map; } #else @interface StdMapIntWrapper : NSObject { @private void *wrapper_map; } #endif - (int) valueForKey:(int)aKey; - (void) setValue:(int)aValue forKey:(int)aKey; - (void) removeValueForKey:(int)aKey; @end #endif // _Pantomime_H_StdMapIntWrapper
  52. 52. Objective-C++ Map (2)#import <Pantomime/StdMapIntWrapper.h> - (void) removeValueForKey:(int)aKey { std::map<int, int>::iterator it;@implementation StdMapIntWrapper it = (* wrapper_map).find(aKey); if (it != (* wrapper_map).end())- (id) init {{ (* wrapper_map).erase(it); self = [super init]; } if (self) } { wrapper_map = new std::map<int, int>; - (void) dealloc } { return self; wrapper_map = NULL;} [super dealloc]; }- (int) valueForKey:(int)aKey{ @end return (* wrapper_map)[aKey];}- (void) setValue:(int)aValue forKey:(int)aKey{ (* wrapper_map)[aKey] = aValue;}
  53. 53. //include+#include <Pantomime/StdMapIntWrapper.h>//-static NSMapTable *fd_to_cfsocket;+static StdMapIntWrapper *fd_to_cfsocket;//- fd_to_cfsocket = NSCreateMapTable(NSIntMapKeyCallBacks, NSIntMapValueCallBacks, 16);+ fd_to_cfsocket = [[StdMapIntWrapper alloc] init];//- NSMapInsert(fd_to_cfsocket, (void *)[_connection fd], (void *)_socket);+ [fd_to_cfsocket setValue:(void *)_socket forKey:(void *)[_connection fd]];//- socket = (CFSocketRef)NSMapGet(fd_to_cfsocket, (void*)fd);+ socket = (CFSocketRef)[fd_to_cfsocket valueForKey:(void*)fd];
  54. 54. : Modified UTF-7• Pantomime Modified UTF-7 ••
  55. 55. - (NSString *) modifiedUTF7String{ NSString *str = self; unichar c; uint index = 0; BOOL nowBase64 = NO; NSMutableString *toBase64String = [[NSMutableString alloc] initWithString:@""]; NSMutableString *result = [[NSMutableString alloc] initWithString:@""]; for (; index < [str length]; index++){ c = [str characterAtIndex:index]; if ((0x20 <= c && c <= 0x7e)) { if (nowBase64) { NSString *base64edstr = [self getUTF7Parts:toBase64String]; toBase64String = [[NSMutableString alloc] initWithString:@""]; [result appendString:base64edstr]; [result appendString:@"-"]; nowBase64 = NO; } if (c == 0x26) { [result appendString:@"&-"]; } else { [result appendString:[NSString stringWithCharacters:&c length:1]]; } } else { if (!nowBase64) { nowBase64 = YES; [result appendString:@"&"]; } [toBase64String appendString:[NSString stringWithCharacters:&c length:1]]; } } if (nowBase64) { NSString *base64edstr = [self getUTF7Parts:toBase64String]; [result appendString:base64edstr]; [result appendString:@"-"]; nowBase64 = NO; } return result;}
  56. 56. • Mac OS X• Apple• • Objective-C++
  57. 57. URL• Pantomime • http://www.collaboration-world.com/pantomime• Pantomime iOS fork • https://github.com/smellman/Pantomime
  58. 58. ( )

×