discon
iPhone
Taro 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

    •
    •
    •                   (

    •       Σ( д lll)
Pantomime

•   Objective-C             IMAP/POP/SMTP

    •               Mac OS X      GNUStep

•
•                  2007 / 2 / 5

    •             discon              (ry
1
•
    •   Mac OS X 10.2



•
    •   NSDebug

•
    •
2
•   GNUStep

    •
•   SMTP

    •                     (



•   iOS

    •         Apple

    •         Apple
•
    •   NSString cString

    •   NSFileManager fileAttributesAtPath:traverseLink:

•                      xcode

•
NSFileManager
fileAttributesAtPath:traverseLink:
attributesOfItemAtPath:error:


- attributes = [[NSFileManager defaultManager] fileAttributesAtPath: thePath traverseLink: NO];
+ NSError *error = nil;
+ attributes = [[NSFileManager defaultManager] attributesOfItemAtPath: thePath error: &error];
•   Pantomime       openssl



    •   openssl-xcode         openssl
                  iPhone

        •   https://github.com/sjlombardo/openssl-xcode

•                             libcrypt.a                  libssl.a
                                    orz
•   libssl.a                openssl-xcode

    •   https://github.com/smellman/openssl-xcode

    •
•   libssl.a   libcrypt.a
GNUStep

•   GNUStep



    •                #ifdef MACOSX
              (iOS        )

•   GNUStep    Mac OS X                                        Mac OS
    X

•                                    OK (Search and Destroy)
-#ifdef MACOSX
 #include <Pantomime/CWMacOSXGlue.h>
-#endif


 Mac OS X
-#ifdef MACOSX
   #include <CoreFoundation/CFString.h>
   #include <CoreFoundation/CFStringEncodingExt.h>
  -#else
  -#include <GNUstepBase/GSCategories.h>
  -#endif

else                    GNUStep
iOS

•   iOS

    •
•
    •
        •
        •
NSHost


•                          [[NSHost currentHost] name]

    •
        •   gethostname

        •           NSString
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,")];
NSCalendarDate



•   iOS             Mac OS X   Legacy API



•   Pantomime

    •
NSCalendarDate

•   NSCalendarDate

    •   NSDate

•   descriptionWithCalendarFormat

    •   NSDateFormatter

•
    •   NSCalendar NSDateCompoments

•   timeIntervalSince1970

    •   NSDate
-    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];
NSMapTable


•   NSMapTable
    typedef struct _NSMapTable NSMapTable;


    •   Mac OS X 10.0   10.4

•
    •                          int

•   NSMapTable                               iOS
•   NSCreateMapTable

    •   NSCreateMapTable(NSObjectMapKeyCallBacks,
        NSObjectMapValueCallBacks, 128);

•                          Map
    NSMutableDictionary
NSMutableDictionary
//
- NSMapTable *_table;
+ NSMutableDictionary *_table;

//
- _table = NSCreateMapTable(NSObjectMapKeyCallBacks, NSObjectMapValueCallBacks, 128);
+ _table = [[NSMutableDictionary alloc] initWithCapacity:128];

//
-     NSMapInsert(_table, aUID, aDate);
+    [_table setObject:aDate forKey:aUID];
int


•   NSCreateMapTable int

    •   NSCreateMapTable(NSIntMapKeyCallBacks,
        NSObjectMapValueCallBacks, 128);

•   NSMutableDictionary

    •   |←    |             (^o^ )
•                   Map

•   Java                  (Generic)

    •   Generic

        •
            •   std::map

                •    C++ !!!!!!
C++ iPhone

•   iPhone        C++

•            Objective-C

•   Objective-C++

    •   (    д)     (   д   )   (д    )

•
    •
    •                                C++   Objective-C++   ...
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
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;
}
//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];
: Modified UTF-7



•   Pantomime   Modified UTF-7

    •
•
- (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;
}
•   Mac OS X

•   Apple

•
    •   Objective-C++
URL


•   Pantomime

    •   http://www.collaboration-world.com/pantomime

•   Pantomime iOS fork

    •   https://github.com/smellman/Pantomime
(   )

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

  • 1.
    discon iPhone Taro Matsuzawa akabtm (@smellman) at sumaben kanto #11
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
    1997 • • Windows 95 OSR2 • MMX Pentium 200Mhz
  • 8.
    1999 • • English Speaking Society (E.S.S.) •
  • 9.
    2000 • • • Mozilla Party JP 1.0 ( OSS ) • • • Linux • • E.S.S.
  • 10.
    2001 • • • • Tokyo Linux Entertainment Community(TLEC) • WEB
  • 11.
    2002 • • • VB ( ) • Mozilla Party 3.0 JP • • •
  • 12.
    2003 • • • • Mozilla Party JP 4.0 • • 1000 40
  • 13.
    2004 • (5 ) • • • • • ○
  • 14.
    2005 • C Magazine 2005/10 2 Firefox Piro C++ •
  • 15.
    2006 • • •
  • 16.
    2007 • Software Design 2007/04 Firefox ( ) • • ○○ • • •
  • 17.
    2008 • • KBMJ • Firefox 3 Hacks ( ) • •
  • 18.
    2009 • • • Software Design Firefox 2009.11 2010.04 • OSS EC
  • 19.
    2010 • iPhone In App Purchase 2 • • ( )
  • 20.
    2011 • ( ) • •
  • 21.
    iPhone • • iPhone • GUI • •
  • 22.
    • iPhone • • • IMAP •
  • 23.
  • 24.
    IMAP • • i.softbank.jp • • • •
  • 25.
    • • • SSL •
  • 26.
    • ... • • ( )
  • 27.
    Pantomime Mac OS X/GNUStep LGPL2 • 2007 • • ... • •
  • 28.
    LGPL2 iPhone • LGPL2 (ex. cocos2d-iphone ) • • • • OK • • • ( • Σ( д lll)
  • 30.
    Pantomime • Objective-C IMAP/POP/SMTP • Mac OS X GNUStep • • 2007 / 2 / 5 • discon (ry
  • 31.
    1 • • Mac OS X 10.2 • • NSDebug • •
  • 32.
    2 • GNUStep • • SMTP • ( • iOS • Apple • Apple
  • 33.
    • NSString cString • NSFileManager fileAttributesAtPath:traverseLink: • xcode •
  • 34.
  • 35.
    attributesOfItemAtPath:error: - attributes =[[NSFileManager defaultManager] fileAttributesAtPath: thePath traverseLink: NO]; + NSError *error = nil; + attributes = [[NSFileManager defaultManager] attributesOfItemAtPath: thePath error: &error];
  • 36.
    Pantomime openssl • openssl-xcode openssl iPhone • https://github.com/sjlombardo/openssl-xcode • libcrypt.a libssl.a orz
  • 37.
    libssl.a openssl-xcode • https://github.com/smellman/openssl-xcode • • libssl.a libcrypt.a
  • 38.
    GNUStep • GNUStep • #ifdef MACOSX (iOS ) • GNUStep Mac OS X Mac OS X • OK (Search and Destroy)
  • 39.
    -#ifdef MACOSX #include<Pantomime/CWMacOSXGlue.h> -#endif Mac OS X
  • 40.
    -#ifdef MACOSX #include <CoreFoundation/CFString.h> #include <CoreFoundation/CFStringEncodingExt.h> -#else -#include <GNUstepBase/GSCategories.h> -#endif else GNUStep
  • 41.
    iOS • iOS • • • • •
  • 42.
    NSHost • [[NSHost currentHost] name] • • gethostname • NSString
  • 43.
    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,")];
  • 44.
    NSCalendarDate • iOS Mac OS X Legacy API • Pantomime •
  • 45.
    NSCalendarDate • NSCalendarDate • NSDate • descriptionWithCalendarFormat • NSDateFormatter • • NSCalendar NSDateCompoments • timeIntervalSince1970 • NSDate
  • 46.
    - 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];
  • 47.
    NSMapTable • NSMapTable typedef struct _NSMapTable NSMapTable; • Mac OS X 10.0 10.4 • • int • NSMapTable iOS
  • 48.
    NSCreateMapTable • NSCreateMapTable(NSObjectMapKeyCallBacks, NSObjectMapValueCallBacks, 128); • Map NSMutableDictionary
  • 49.
    NSMutableDictionary // - NSMapTable *_table; +NSMutableDictionary *_table; // - _table = NSCreateMapTable(NSObjectMapKeyCallBacks, NSObjectMapValueCallBacks, 128); + _table = [[NSMutableDictionary alloc] initWithCapacity:128]; // - NSMapInsert(_table, aUID, aDate); + [_table setObject:aDate forKey:aUID];
  • 50.
    int • NSCreateMapTable int • NSCreateMapTable(NSIntMapKeyCallBacks, NSObjectMapValueCallBacks, 128); • NSMutableDictionary • |← | (^o^ )
  • 51.
    Map • Java (Generic) • Generic • • std::map • C++ !!!!!!
  • 52.
    C++ iPhone • iPhone C++ • Objective-C • Objective-C++ • ( д) ( д ) (д ) • • • C++ Objective-C++ ...
  • 53.
    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
  • 54.
    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; }
  • 55.
    //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];
  • 56.
    : Modified UTF-7 • Pantomime Modified UTF-7 • •
  • 57.
    - (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; }
  • 58.
    Mac OS X • Apple • • Objective-C++
  • 59.
    URL • Pantomime • http://www.collaboration-world.com/pantomime • Pantomime iOS fork • https://github.com/smellman/Pantomime
  • 60.
    ( )