Skip to content

Commit

Permalink
Merge branch 'master' of git://github.com/sintaxi/phonegap
Browse files Browse the repository at this point in the history
  • Loading branch information
Joe Bowser committed Jun 5, 2009
2 parents 59c53cb + 554c049 commit d37e7f8
Show file tree
Hide file tree
Showing 33 changed files with 1,408 additions and 5,614 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
.DS_Store
.*.sw?
tmp/
*.xcodeproj/* !*.xcodeproj/project.pbxproj
lib/iphone/phonegap-min.js
lib/iphone/phonegap.js
15 changes: 15 additions & 0 deletions iphone/Classes/Categories.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//
// Categories.h
// PhoneGap
//
// Created by Shazron Abdullah on 26/05/09.
// Copyright 2009 Nitobi Software. All rights reserved.
//


@interface NSMutableDictionary(NSDictionary_Extension)

- (bool) existsValue:(NSString*)expectedValue forKey:(NSString*)key;
- (NSUInteger) integerValueForKey:(NSString*)key defaultValue:(NSUInteger)defaultValue withRange:(NSRange)range;

@end
48 changes: 48 additions & 0 deletions iphone/Classes/Categories.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
//
// Categories.m
// PhoneGap
//
// Created by Shazron Abdullah on 26/05/09.
// Copyright 2009 Nitobi Software. All rights reserved.
//

#import "Categories.h"
#import <math.h>

@implementation NSMutableDictionary(NSDictionary_Extension)

- (bool) existsValue:(NSString*)expectedValue forKey:(NSString*)key
{
id val = [self valueForKey:key];
bool exists = false;
if (val != nil) {
exists = [(NSString*)val compare:expectedValue options:NSCaseInsensitiveSearch] == 0;
}

return exists;
}

- (NSUInteger) integerValueForKey:(NSString*)key defaultValue:(NSUInteger)defaultValue withRange:(NSRange)range
{
NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];
[numberFormatter setRoundingMode:NSNumberFormatterRoundCeiling];

NSUInteger value = defaultValue;

id val = [self valueForKey:key];
if (val != nil) {
NSNumber* number = [numberFormatter numberFromString:(NSString*)val];
value = [number unsignedIntValue];
}

[numberFormatter release];

// min, max checks
value = MAX(range.location, value);
value = MIN(range.length, value);

return value;
}

@end

75 changes: 66 additions & 9 deletions iphone/Classes/Contacts.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,79 @@

#import <Foundation/Foundation.h>
#import <AddressBook/ABAddressBook.h>
#import <AddressBookUI/AddressBookUI.h>
#import "PhoneGapCommand.h"

@interface Contacts : PhoneGapCommand {
@interface Contacts : PhoneGapCommand <ABNewPersonViewControllerDelegate,
ABPersonViewControllerDelegate,
ABPeoplePickerNavigationControllerDelegate
>
{
ABAddressBookRef addressBook;
NSArray *allPeople;
CFIndex nPeople;
NSArray* allPeople;
}

@property (getter=getAddressBook,assign) ABAddressBookRef addressBook;
@property (getter=getContacts,assign) NSArray *allPeople;
/*
* allContacts
*
* arguments:
* 1: this is the javascript function that will be called with the results, the first parameter passed to the
* javascript function is a javascript array
* options:
* nameFilter: filter the results by this name (wildcards ok), if available
* pageSize: maximum number of results to retrieve
* pageNumber: page number of results to retrieve
*/
- (void) allContacts:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options;

/*
* newContact
*
* arguments:
* 1: first name of the new contact
* 2: last name of the new contact
* options:
* gui: set to true to allow the user to add a new contact through the iPhone contact editor
* successCallback: this is the javascript function that will be called with the newly created contact as a JSON object
*/
- (void) newContact:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options;

/*
* displayContact
*
* arguments:
* 1: recordID of the contact to display in the iPhone contact display
* options:
* allowsEditing: set to true to allow the user to edit the contact
*/
- (void) displayContact:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options;

/*
* chooseContact
*
* arguments:
* 1: this is the javascript function that will be called with the contact data as a JSON object (as the first param)
* options:
* allowsEditing: set to true to not choose the contact, but to edit it in the iPhone contact editor
*/
- (void) chooseContact:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options;

-(PhoneGapCommand*) initWithWebView:(UIWebView*)theWebView;
- (void) newPersonViewController:(ABNewPersonViewController *)newPersonViewController didCompleteWithNewPerson:(ABRecordRef)person;
- (BOOL) personViewController:(ABPersonViewController *)personViewController shouldPerformDefaultActionForPerson:(ABRecordRef)person
property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifierForValue;

- (void)get:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options;
- (void) addressBookDirty;
- (void) dealloc;

@end

@interface ContactsPicker : ABPeoplePickerNavigationController
{
BOOL allowsEditing;
NSString* jsCallback;
}

- (void) displayContact:(ABRecordRef *) person;
- (void) addContact;
@property BOOL allowsEditing;
@property (retain) NSString* jsCallback;

@end
Loading

0 comments on commit d37e7f8

Please sign in to comment.