Skip to content

Commit

Permalink
Creative Commons Non Commercial license added
Browse files Browse the repository at this point in the history
  • Loading branch information
alessandroboron committed Nov 27, 2012
1 parent 803fca2 commit e7e919a
Show file tree
Hide file tree
Showing 86 changed files with 538 additions and 593 deletions.
Binary file modified .DS_Store
Binary file not shown.
67 changes: 20 additions & 47 deletions Timeline.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions Timeline/AppDelegate.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//"This work is licensed under the Attribution-NonCommercial-ShareAlike 3.0 Unported License.
// To view a copy of the license, visit http://http://creativecommons.org/licenses/by-nc-sa/3.0/ "
//
// AppDelegate.h
// Timeline
Expand Down
2 changes: 2 additions & 0 deletions Timeline/AppDelegate.m
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//"This work is licensed under the Attribution-NonCommercial-ShareAlike 3.0 Unported License.
// To view a copy of the license, visit http://http://creativecommons.org/licenses/by-nc-sa/3.0/ "
//
// AppDelegate.m
// Timeline
Expand Down
2 changes: 2 additions & 0 deletions Timeline/Categories/NSString+MD5.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//"This work is licensed under the Attribution-NonCommercial-ShareAlike 3.0 Unported License.
// To view a copy of the license, visit http://http://creativecommons.org/licenses/by-nc-sa/3.0/ "
//
// NSString+MD5.h
// Timeline
Expand Down
2 changes: 2 additions & 0 deletions Timeline/Categories/NSString+MD5.m
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//"This work is licensed under the Attribution-NonCommercial-ShareAlike 3.0 Unported License.
// To view a copy of the license, visit http://http://creativecommons.org/licenses/by-nc-sa/3.0/ "
//
// NSString+MD5.m
// Timeline
Expand Down
8 changes: 8 additions & 0 deletions Timeline/DBController/DBController.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@

- (void)insertTimeline:(Timeline *)timeline;

- (BOOL)isUserInDB:(NSString *)user;

- (void)insertUser:(NSString *)user;

- (BOOL)isUser:(NSString *)user inTimeline:(NSString *)timelineId;

- (void)insertUser:(NSString *)user inTimeline:(NSString *)timelineId;

- (BOOL)isTimeline:(NSString *)timelineId titleEqualTo:(NSString *)timelineTitle;

- (BOOL)isTimeline:(NSString *)timelineId sharedEqualTo:(BOOL)shared;
Expand Down
215 changes: 213 additions & 2 deletions Timeline/DBController/DBController.m
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ - (void)checkAndCreateDB;
- (NSString *)databasePath;

- (void)insertTimeline:(Timeline *)timeline;
- (NSArray *)timelinesForUser:(NSString *)user;
- (NSArray *)timelines;
- (Timeline *)timelineWithId:(NSString *)timeline_Id;
- (void)insertEventInDB:(Event *)event;
- (NSArray *)eventsInTimeline:(Timeline *)timeline;
- (Event *)eventWithId:(NSString *)event_Id;
Expand Down Expand Up @@ -82,8 +84,18 @@ - (id)initDB{
//This method is used to fetch the Timelines from the DB
- (NSMutableArray *)fetchTimelinesFromDB{

NSArray *timelinesForUser = [self timelinesForUser:[Utility settingField:kXMPPUserIdentifier]];

NSMutableArray *timelines = [[NSMutableArray alloc] initWithCapacity:[timelinesForUser count]];

for (NSString *tId in timelinesForUser) {
Timeline *t = [self timelineWithId:tId];
[timelines addObject:t];
}


//Get timelines
NSMutableArray *timelines = [[self timelines] mutableCopy];
// NSMutableArray *timelines = [[self timelines] mutableCopy];

return timelines;
}
Expand Down Expand Up @@ -509,6 +521,7 @@ - (BOOL)isTimelineInDB:(NSString *)timelineId{

}


//This method is used to insert a timeline in the DB
- (void)insertTimeline:(Timeline *)timeline{

Expand All @@ -534,6 +547,163 @@ - (void)insertTimeline:(Timeline *)timeline{
}
}

- (BOOL)isUserInDB:(NSString *)user{

BOOL present = NO;

//Get the database
FMDatabase *db = [FMDatabase databaseWithPath:[self databasePath]];

@try {
//Open the connection
[db open];

//Select the category with a given name
FMResultSet *result = [db executeQuery:@"SELECT * FROM Users WHERE Username = ?",user];

//If the category is present
if ([result next]) {
present = YES;
}
}

@catch (NSException *exception) {
NSLog(@"Error: %@",[exception description]);
}

@finally {
//Close the connection
[db close];
}

return present;

}

- (void)insertUser:(NSString *)user{

//Get the database
FMDatabase *db = [FMDatabase databaseWithPath:[self databasePath]];

@try {
[db open];

[db executeUpdate:@"INSERT INTO Users (Username) VALUES (?)",user];

if ([db hadError]) {
NSLog(@"Err %d: %@", [db lastErrorCode], [db lastErrorMessage]);
}
}

@catch (NSException *exception) {
NSLog(@"Error: %@",[exception description]);
}

@finally {
[db close];
}

}

- (BOOL)isUser:(NSString *)user inTimeline:(NSString *)timelineId{

BOOL present = NO;

//Get the database
FMDatabase *db = [FMDatabase databaseWithPath:[self databasePath]];

@try {
//Open the connection
[db open];

//Select the category with a given name
FMResultSet *result = [db executeQuery:@"SELECT * FROM UsersInTimeline WHERE Id_User = ? AND Id_Timeline = ?",user,timelineId];

//If the category is present
if ([result next]) {
present = YES;
}
}

@catch (NSException *exception) {
NSLog(@"Error: %@",[exception description]);
}

@finally {
//Close the connection
[db close];
}

return present;
}

- (void)insertUser:(NSString *)user inTimeline:(NSString *)timelineId{

if (![self isUser:user inTimeline:timelineId]) {

//Get the database
FMDatabase *db = [FMDatabase databaseWithPath:[self databasePath]];

@try {
[db open];

[db executeUpdate:@"INSERT INTO UsersInTimeline (Id_Timeline,Id_User) VALUES (?,?)",timelineId,user];

if ([db hadError]) {
NSLog(@"Err %d: %@", [db lastErrorCode], [db lastErrorMessage]);
}
}

@catch (NSException *exception) {
NSLog(@"Error: %@",[exception description]);
}

@finally {
[db close];
}
}
}


- (NSArray *)timelinesForUser:(NSString *)user{

//Initialize a mutable array to store the timelines result
NSMutableArray *timelinesForUser = [[NSMutableArray alloc] init];

//Get the DB
FMDatabase *db = [FMDatabase databaseWithPath:[self databasePath]];

@try {
//Open a connection
[db open];

//Fetch the categories
FMResultSet *result = [db executeQuery:@"SELECT * FROM UsersInTimeline WHERE Id_User = ?",user];

//For each element
while ([result next]) {
//Initialize the Timeline object
NSString *tId = [result stringForColumn:@"Id_Timeline"];
[timelinesForUser addObject:tId];
}
}

//Exception catched
@catch (NSException *exception) {
NSLog(@"Error: %@",[exception description]);
}

//Close the connection
@finally {
//Close the connection
[db close];
}

//Return a immutable version of the array
return [timelinesForUser copy];

}

- (NSArray *)timelines{

//Initialize a mutable array to store the timelines result
Expand All @@ -547,7 +717,7 @@ - (NSArray *)timelines{
[db open];

//Fetch the categories
FMResultSet *result = [db executeQuery:@"SELECT * FROM Timelines"];
FMResultSet *result = [db executeQuery:@"SELECT * FROM Timelines WHERE Creator = ?",[Utility settingField:kXMPPUserIdentifier]];

//For each element
while ([result next]) {
Expand Down Expand Up @@ -580,6 +750,47 @@ - (NSArray *)timelines{

}

- (Timeline *)timelineWithId:(NSString *)timeline_Id{

Timeline *timeline = nil;

//Get the DB
FMDatabase *db = [FMDatabase databaseWithPath:[self databasePath]];

@try {
//Open a connection
[db open];

//Fetch the categories
FMResultSet *result = [db executeQuery:@"SELECT * FROM Timelines WHERE Id = ?",timeline_Id];

//For each element
while ([result next]) {
//Initialize the Timeline object
NSString *tId = [result stringForColumn:@"Id"];
NSString *title = [result stringForColumn:@"Title"];
NSString *creator = [result stringForColumn:@"Creator"];
BOOL shared = [result boolForColumn:@"Shared"];
//Insert into timelines array
timeline = [[Timeline alloc] initTimelineWithId:tId title:title creator:creator shared:shared];
}
}

//Exception catched
@catch (NSException *exception) {
NSLog(@"Error: %@",[exception description]);
}

//Close the connection
@finally {
//Close the connection
[db close];
}

//Return the event
return timeline;
}

- (BOOL)isEventInDB:(NSString *)eventId{

BOOL present = NO;
Expand Down
2 changes: 2 additions & 0 deletions Timeline/Model/BaseEvent/BaseEvent.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//"This work is licensed under the Attribution-NonCommercial-ShareAlike 3.0 Unported License.
// To view a copy of the license, visit http://http://creativecommons.org/licenses/by-nc-sa/3.0/ "
//
// BaseEvent.h
// Timeline
Expand Down
2 changes: 2 additions & 0 deletions Timeline/Model/BaseEvent/BaseEvent.m
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//"This work is licensed under the Attribution-NonCommercial-ShareAlike 3.0 Unported License.
// To view a copy of the license, visit http://http://creativecommons.org/licenses/by-nc-sa/3.0/ "
//
// BaseEvent.m
// Timeline
Expand Down
2 changes: 2 additions & 0 deletions Timeline/Model/Emotion/Emotion.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//"This work is licensed under the Attribution-NonCommercial-ShareAlike 3.0 Unported License.
// To view a copy of the license, visit http://http://creativecommons.org/licenses/by-nc-sa/3.0/ "
//
// Emotion.h
// Timeline
Expand Down
2 changes: 2 additions & 0 deletions Timeline/Model/Emotion/Emotion.m
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//"This work is licensed under the Attribution-NonCommercial-ShareAlike 3.0 Unported License.
// To view a copy of the license, visit http://http://creativecommons.org/licenses/by-nc-sa/3.0/ "
//
// Emotion.m
// Timeline
Expand Down
2 changes: 2 additions & 0 deletions Timeline/Model/Event/Event.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//"This work is licensed under the Attribution-NonCommercial-ShareAlike 3.0 Unported License.
// To view a copy of the license, visit http://http://creativecommons.org/licenses/by-nc-sa/3.0/ "
//
// Event.h
// Timeline
Expand Down
2 changes: 2 additions & 0 deletions Timeline/Model/Event/Event.m
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//"This work is licensed under the Attribution-NonCommercial-ShareAlike 3.0 Unported License.
// To view a copy of the license, visit http://http://creativecommons.org/licenses/by-nc-sa/3.0/ "
//
// Event.m
// Timeline
Expand Down
2 changes: 2 additions & 0 deletions Timeline/Model/EventItem/EventItem.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//"This work is licensed under the Attribution-NonCommercial-ShareAlike 3.0 Unported License.
// To view a copy of the license, visit http://http://creativecommons.org/licenses/by-nc-sa/3.0/ "
//
// EventItem.h
// Timeline
Expand Down
2 changes: 2 additions & 0 deletions Timeline/Model/EventItem/EventItem.m
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//"This work is licensed under the Attribution-NonCommercial-ShareAlike 3.0 Unported License.
// To view a copy of the license, visit http://http://creativecommons.org/licenses/by-nc-sa/3.0/ "
//
// EventItem.m
// Timeline
Expand Down
2 changes: 2 additions & 0 deletions Timeline/Model/EventItem/SampleNote/SampleNote.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//"This work is licensed under the Attribution-NonCommercial-ShareAlike 3.0 Unported License.
// To view a copy of the license, visit http://http://creativecommons.org/licenses/by-nc-sa/3.0/ "
//
// SampleNote.h
// Timeline
Expand Down
2 changes: 2 additions & 0 deletions Timeline/Model/EventItem/SampleNote/SampleNote.m
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//"This work is licensed under the Attribution-NonCommercial-ShareAlike 3.0 Unported License.
// To view a copy of the license, visit http://http://creativecommons.org/licenses/by-nc-sa/3.0/ "
//
// SampleNote.m
// Timeline
Expand Down
2 changes: 2 additions & 0 deletions Timeline/Model/EventItem/SimplePicture/SimplePicture.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//"This work is licensed under the Attribution-NonCommercial-ShareAlike 3.0 Unported License.
// To view a copy of the license, visit http://http://creativecommons.org/licenses/by-nc-sa/3.0/ "
//
// SimplePicture.h
// Timeline
Expand Down
2 changes: 2 additions & 0 deletions Timeline/Model/EventItem/SimplePicture/SimplePicture.m
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//"This work is licensed under the Attribution-NonCommercial-ShareAlike 3.0 Unported License.
// To view a copy of the license, visit http://http://creativecommons.org/licenses/by-nc-sa/3.0/ "
//
// SimplePicture.m
// Timeline
Expand Down
2 changes: 2 additions & 0 deletions Timeline/Model/EventItem/SimpleRecording/SimpleRecording.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//"This work is licensed under the Attribution-NonCommercial-ShareAlike 3.0 Unported License.
// To view a copy of the license, visit http://http://creativecommons.org/licenses/by-nc-sa/3.0/ "
//
// SimpleRecording.h
// Timeline
Expand Down
2 changes: 2 additions & 0 deletions Timeline/Model/EventItem/SimpleRecording/SimpleRecording.m
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//"This work is licensed under the Attribution-NonCommercial-ShareAlike 3.0 Unported License.
// To view a copy of the license, visit http://http://creativecommons.org/licenses/by-nc-sa/3.0/ "
//
// SimpleRecording.m
// Timeline
Expand Down
2 changes: 2 additions & 0 deletions Timeline/Model/EventItem/SimpleVideo/SimpleVideo.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//"This work is licensed under the Attribution-NonCommercial-ShareAlike 3.0 Unported License.
// To view a copy of the license, visit http://http://creativecommons.org/licenses/by-nc-sa/3.0/ "
//
// SimpleVideo.h
// Timeline
Expand Down
2 changes: 2 additions & 0 deletions Timeline/Model/EventItem/SimpleVideo/SimpleVideo.m
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//"This work is licensed under the Attribution-NonCommercial-ShareAlike 3.0 Unported License.
// To view a copy of the license, visit http://http://creativecommons.org/licenses/by-nc-sa/3.0/ "
//
// SimpleVideo.m
// Timeline
Expand Down
2 changes: 2 additions & 0 deletions Timeline/Model/Timeline/Timeline.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//"This work is licensed under the Attribution-NonCommercial-ShareAlike 3.0 Unported License.
// To view a copy of the license, visit http://http://creativecommons.org/licenses/by-nc-sa/3.0/ "
//
// Timeline.h
// Timeline
Expand Down
Loading

0 comments on commit e7e919a

Please sign in to comment.