Skip to content

Commit

Permalink
First commit
Browse files Browse the repository at this point in the history
  • Loading branch information
alunny committed Jul 16, 2009
0 parents commit fe0b3d9
Show file tree
Hide file tree
Showing 39 changed files with 9,231 additions and 0 deletions.
27 changes: 27 additions & 0 deletions Classes/Contacts.h
@@ -0,0 +1,27 @@
/*
* Contact.h
*
* Created by Nitobi on 12/12/08.
* Copyright 2008 Nitobi. All rights reserved.
*
*/

#import <Foundation/Foundation.h>
#import <AddressBook/ABAddressBook.h>

@interface Contacts : NSObject {
ABAddressBookRef addressBook;
NSArray *allPeople;
CFIndex nPeople;
}

@property (getter=getAddressBook,assign) ABAddressBookRef addressBook;
@property (getter=getContacts,assign) NSArray *allPeople;

//- (NSString *)stringValueForRow:(NSInteger)row;

- (id)init;
- (void) displayContact:(ABRecordRef *) person;
- (void) addContact;

@end
86 changes: 86 additions & 0 deletions Classes/Contacts.m
@@ -0,0 +1,86 @@
/*
* Contact.m
*
* Created by Nitobi on 2/3/09
* Copyright 2008 Nitobi. All rights reserved.
* Rob Ellis rob.ellis@nitobi.com
*
*/


#import <AddressBook/AddressBook.h>
#import "Contacts.h"

@implementation Contacts

@synthesize addressBook;
@synthesize allPeople;

- (id)init
{
self = [super init];
addressBook = ABAddressBookCreate();
return self;
}

- (NSMutableString *)getContacts {
NSMutableString *update = [[[NSMutableString alloc] init] autorelease];

if (allPeople == nil) {
allPeople = (NSArray *)ABAddressBookCopyArrayOfAllPeople(self.addressBook);
CFIndex numberOfPeople = ABAddressBookGetPersonCount(self.addressBook);

[update appendString:@"var _contacts=["];

for (int i=0;i < numberOfPeople;i++) {
ABRecordRef ref = CFArrayGetValueAtIndex(allPeople,i);

if (ABRecordCopyValue(ref, kABPersonFirstNameProperty) != nil && ABRecordCopyValue(ref, kABPersonLastNameProperty) != nil) {
CFStringRef firstName = ABRecordCopyValue(ref, kABPersonFirstNameProperty);
CFStringRef lastName = ABRecordCopyValue(ref, kABPersonLastNameProperty);
CFStringRef phoneNumber = ABMultiValueCopyValueAtIndex(ABRecordCopyValue(ref,kABPersonPhoneProperty) ,0);

NSString *contactFirstLast = [NSString stringWithFormat:@"%@ %@",firstName, lastName];
NSString *contactFirstLast2 = [NSString stringWithFormat:@"{'name':'%@','phone':'%@'}",contactFirstLast,phoneNumber];
[update appendFormat:@"%@", contactFirstLast2];
if (i+1 != numberOfPeople) {
[update appendFormat:@","];
}

CFRelease(firstName);
CFRelease(lastName);
CFRelease(phoneNumber);
}
}

[update appendString:@"];"];
}
return update;
}

- (void) addContact {

ABAddressBookRef libroDirec = ABAddressBookCreate();
ABRecordRef persona = ABPersonCreate();

ABRecordSetValue(persona, kABPersonFirstNameProperty, @"kate" , nil);
ABRecordSetValue(persona, kABPersonLastNameProperty, @"Hutson", nil);
ABAddressBookAddRecord(libroDirec, persona, nil);
ABAddressBookSave(libroDirec, nil);

CFRelease(persona);
}


- (void) displayContact:(ABRecordRef *) person {
NSLog(@"HERE");
}

- (ABAddressBookRef)getAddressBook {
if (nil == addressBook)
{
addressBook = ABAddressBookCreate();
}
return addressBook;
}
@end
16 changes: 16 additions & 0 deletions Classes/Device.h
@@ -0,0 +1,16 @@
/*
* Device.h
* Used to display Device centric details handset.
*
* Created by Nitobi on 12/12/08.
* Copyright 2008 Nitobi. All rights reserved.
*/

#import <UIKit/UIKit.h>
#import <UIKit/UIDevice.h>

@interface Device : NSObject {
UIDevice *myCurrentDevice;
}

@end
47 changes: 47 additions & 0 deletions Classes/Device.m
@@ -0,0 +1,47 @@
/*
* Device.m
* Used to display Device centric details handset.
*
* Created by Nitobi on 12/12/08.
* Copyright 2008 Nitobi. All rights reserved.
*/

#import "Device.h"

@implementation Device

/*
* init
* returns a JS String with various device settings
* - gap enabled
* - version
* - Device model
* - Device Version
* - Device UUID
*/
- (NSString *)init{

myCurrentDevice = [UIDevice currentDevice];
//
// return jsCallBack = [[NSString alloc] initWithFormat:@"\
// __gap = true; \
// __gap_version='0.2'; \
// __gap_device_model='%s'; \
// __gap_device_version='%s';\
// __gap_device_uniqueid='%s';",
// [[myCurrentDevice model] UTF8String],
// [[myCurrentDevice systemVersion] UTF8String],
// [[myCurrentDevice uniqueIdentifier] UTF8String]
// ];


return [[NSString alloc] initWithFormat:@"Device={};Device.platform='%s';Device.version='%s';Device.uuid='%s';",[[myCurrentDevice model] UTF8String], [[myCurrentDevice systemVersion] UTF8String], [[myCurrentDevice uniqueIdentifier] UTF8String] ];
}

- (void)dealloc {
[myCurrentDevice release];
[super dealloc];

}

@end
18 changes: 18 additions & 0 deletions Classes/File.h
@@ -0,0 +1,18 @@
//
// File.h
// PhoneGap
//
// Created by Nitobi on 19/12/08.
// Copyright 2008 Nitobi. All rights reserved.
//

#import <Foundation/Foundation.h>


@interface File : NSObject {

}



@end
14 changes: 14 additions & 0 deletions Classes/File.m
@@ -0,0 +1,14 @@
//
// File.m
// PhoneGap
//
// Created by Nitobi on 19/12/08.
// Copyright 2008 Nitobi. All rights reserved.
//

#import "File.h"


@implementation File

@end
31 changes: 31 additions & 0 deletions Classes/Image.h
@@ -0,0 +1,31 @@
/*
* Image.h
* PhoneGap
*
* Created by Nitobi on 04/02/09.
* Copyright 2009 Nitobi. All rights reserved.
*
*/

#import <Foundation/Foundation.h>


@interface Image : NSObject {
IBOutlet UIWindow *window;
IBOutlet UIWebView *webView;

UIImagePickerController *picker; // added by urbian
NSString *photoUploadUrl; // added by urbian
NSString *lastUploadedPhoto; // added by urbian
NSURLConnection *conn; // added by urbian
NSMutableData *receivedData; // added by urbian

}

@property (nonatomic, retain) UIImagePickerController *imagePickerController;
@property (nonatomic, retain) UIWindow *window;

- (void) imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image2 editingInfo:(NSDictionary *)editingInfo;
- (void) imagePickerControllerDidCancel:(UIImagePickerController *)picker;

@end

0 comments on commit fe0b3d9

Please sign in to comment.