Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

halfway working

  • Loading branch information...
commit d1f3844861e3e4e78d4948a3793cc2738498a32e 1 parent ac805aa
@schacon authored
View
15 AppController.h
@@ -48,22 +48,15 @@ Copyright (C) 2008 Apple Inc. All Rights Reserved.
#import "BrowserViewController.h"
#import "ServerViewController.h"
-#import "TCPServer.h"
-#import "ObjGitCommit.h"
//CLASS INTERFACES:
-@interface AppController : NSObject <UIApplicationDelegate, UITabBarControllerDelegate, TCPServerDelegate>
+@interface AppController : NSObject <UIApplicationDelegate, UITabBarControllerDelegate>
{
UIWindow* _window;
- TCPServer* _server;
- NSInputStream* _inStream;
- NSOutputStream* _outStream;
- BOOL _inReady;
- BOOL _outReady;
- UINavigationController *navigationController;
- UITabBarController *tabBarController;
- ServerViewController *serverViewController;
+ UINavigationController *navigationController;
+ UITabBarController *tabBarController;
+ ServerViewController *serverViewController;
NSString* gitDir;
}
View
79 AppController.m
@@ -8,8 +8,6 @@
*/
-#import "ObjGit.h"
-#import "ObjGitServerHandler.h"
#import "AppController.h"
#import "ProjectViewController.h"
#import "ProjectController.h"
@@ -94,34 +92,13 @@ - (void) applicationDidFinishLaunching:(UIApplication*)application
- (void) dealloc
{
NSLog(@"dealloc");
- [_inStream release];
- [_outStream release];
-
- [_server release];
- [_window release];
-
+ [_window release];
[super dealloc];
}
- (void) setup {
- //[_server release];
- //_server = nil;
-
- [_inStream release];
- _inStream = nil;
- _inReady = NO;
-
- [_outStream release];
- _outStream = nil;
- _outReady = NO;
-
- _server = [TCPServer new];
- [_server setDelegate:self];
- NSError* error;
- if(_server == nil || ![_server start:&error]) {
- NSLog(@"Failed creating server: %@", error);
- return;
- }
+ // TODO: setup the http server
+ NSLog(@"Setup");
gitDir = [self getGitPath];
@@ -132,57 +109,9 @@ - (void) setup {
NSString *thisDir;
while ( (thisDir = [e nextObject]) ) {
NSLog(@"announce:%@", thisDir);
- [_server enableBonjourWithDomain:@"local" applicationProtocol:[TCPServer bonjourTypeFromIdentifier:bonIdentifier] name:thisDir];
+ // TODO: announce http over bonjour
}
}
}
-- (void) openStreams
-{
- NSString *tgitDir = [self getGitPath];
- NSLog(@"gitdir:%@", tgitDir);
-
- [_outStream open];
- [_inStream open];
-
- ObjGit* git = [ObjGit alloc];
- ObjGitServerHandler *obsh = [[ObjGitServerHandler alloc] init];
- NSLog(@"INIT WITH GIT: %@ : %@ : %@ : %@ : %@", obsh, git, tgitDir, _inStream, _outStream);
- [obsh initWithGit:git gitPath:tgitDir input:_inStream output:_outStream];
-
- [_outStream close];
- [_inStream close];
-
- [self setup]; // restart the server
-}
-
-@end
-
-@implementation AppController (TCPServerDelegate)
-
-- (void) serverDidEnableBonjour:(TCPServer*)server withName:(NSString*)string
-{
- //[self.serverViewController setServerName:string];
- //NSLog(@"%@", string);
-}
-
-- (void)didAcceptConnectionForServer:(TCPServer*)server inputStream:(NSInputStream *)istr outputStream:(NSOutputStream *)ostr
-{
- if (_inStream || _outStream || server != _server)
- return;
-
- NSLog(@"accept connection");
-
- [_server stop];
- [_server release];
- _server = nil;
-
- _inStream = istr;
- [_inStream retain];
- _outStream = ostr;
- [_outStream retain];
-
- [self openStreams];
-}
-
@end
View
6 CommitsViewController.h
@@ -4,16 +4,16 @@
//
#import <UIKit/UIKit.h>
-#import "ObjGit.h"
+#import "Git.h"
@interface CommitsViewController : UITableViewController {
- ObjGit *gitRepo;
+ GITRepo *gitRepo;
NSString *gitRef;
NSString *gitSha;
NSMutableArray *commitList;
}
-@property (nonatomic, retain) ObjGit *gitRepo;
+@property (nonatomic, retain) GITRepo *gitRepo;
@property (nonatomic, retain) NSString *gitRef;
@property (nonatomic, retain) NSString *gitSha;
@property (nonatomic, retain) NSMutableArray *commitList;
View
2  CommitsViewController.m
@@ -5,7 +5,7 @@
#import "CommitsViewController.h"
#import "CommitDetailViewController.h"
-#import "ObjGitCommit.h"
+#import "Git.h"
#define ROW_HEIGHT 60
View
2  GITRepo.h
@@ -218,9 +218,9 @@
- (BOOL) updateRef:(NSString *)refName toSha:(NSString *)toSha;
- (BOOL) updateRef:(NSString *)refName toSha:(NSString *)toSha error:(NSError **)error;
-
- (BOOL) writeObject:(NSData *)objectData withType:(NSString *)type size:(NSUInteger)size;
- (BOOL) hasObject: (NSString *)sha1;
+- (void)setDesc:(NSString*)descrip;
@end
View
5 GITRepo.m
@@ -103,6 +103,11 @@ - (id)copyWithZone:(NSZone*)zone
return [[GITRepo allocWithZone:zone] initWithRoot:self.root];
}
+- (void)setDesc:(NSString*)descrip
+{
+ self.desc = descrip;
+}
+
#pragma mark -
#pragma mark Internal Methods
- (NSData*)dataWithContentsOfObject:(NSString*)sha1
View
10 ProjectController.m
@@ -4,7 +4,7 @@
//
#import "ProjectController.h"
-#import "ObjGit.h"
+#import "Git.h"
@interface ProjectController ()
@property (nonatomic, copy, readwrite) NSMutableArray *list;
@@ -17,7 +17,7 @@ @implementation ProjectController
// Custom set accessor to ensure the new list is mutable
- (void)readProjects:(NSString *)projectPath
{
- //NSLog(@"READ PROJECTS:%@", projectPath);
+ NSLog(@"READ PROJECTS:%@", projectPath);
BOOL isDir=NO;
[list release];
list = [[NSMutableArray alloc] init];
@@ -27,9 +27,9 @@ - (void)readProjects:(NSString *)projectPath
NSString *thisDir;
while ( (thisDir = [e nextObject]) ) {
NSString *dir = [projectPath stringByAppendingPathComponent:thisDir];
- ObjGit* git = [[ObjGit alloc] init];
- [git openRepo:dir];
- [git setGitName:thisDir];
+ GITRepo* git = [[GITRepo alloc] init];
+ [git initWithRoot:dir];
+ [git setDesc:thisDir];
[list addObject:git];
}
}
View
6 ProjectDetailViewController.h
@@ -4,12 +4,12 @@
//
#import <UIKit/UIkit.h>
-#import "ObjGit.h"
+#import "Git.h"
@interface ProjectDetailViewController : UITableViewController {
- ObjGit *detailItem;
+ GITRepo *detailItem;
}
-@property (nonatomic, retain) ObjGit *detailItem;
+@property (nonatomic, retain) GITRepo *detailItem;
@end
View
12 ProjectDetailViewController.m
@@ -5,7 +5,7 @@
#import "ProjectDetailViewController.h"
#import "CommitsViewController.h"
-#import "ObjGit.h"
+#import "Git.h"
@implementation ProjectDetailViewController
@@ -19,7 +19,7 @@ - (void)viewWillAppear:(BOOL)animated {
// Scroll the table view to the top before it appears
[self.tableView reloadData];
[self.tableView setContentOffset:CGPointZero animated:NO];
- self.title = [detailItem gitName];
+ self.title = [detailItem desc];
}
// Standard table view data source and delegate methods
@@ -40,7 +40,7 @@ - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger
break;
case 1:
// For the branches section, there is size
- rows = [[detailItem getAllRefs] count];
+ rows = [[detailItem branches] count];
break;
default:
break;
@@ -63,10 +63,10 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
switch (indexPath.section) {
case 0:
- cellText = [detailItem gitName];
+ cellText = [detailItem desc];
break;
case 1:
- cellText = [[[detailItem getAllRefs] objectAtIndex:indexPath.row] objectAtIndex:0];
+ cellText = [[[detailItem branches] objectAtIndex:indexPath.row] objectAtIndex:0];
break;
default:
@@ -100,7 +100,7 @@ - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInte
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
CommitsViewController *commitsViewController = [[CommitsViewController alloc] initWithStyle:UITableViewStylePlain];
- NSArray *refArray = [[detailItem getAllRefs] objectAtIndex:indexPath.row];
+ NSArray *refArray = [[detailItem branches] objectAtIndex:indexPath.row];
NSLog(@"refs:%@", refArray);
commitsViewController.gitRepo = detailItem;
View
1  ProjectViewController.h
@@ -5,6 +5,7 @@
#import <UIKit/UIKit.h>
#import "ProjectController.h"
+#import "Git.h"
@interface ProjectViewController : UITableViewController {
ProjectController *projectController;
View
6 ProjectViewController.m
@@ -5,8 +5,6 @@
#import "ProjectViewController.h"
#import "ProjectDetailViewController.h"
-#import "ObjGit.h"
-
@implementation ProjectViewController
@@ -40,8 +38,8 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
}
// Get the object to display and set the value in the cell
- ObjGit *itemAtIndex = [projectController objectInListAtIndex:indexPath.row];
- cell.text = [itemAtIndex gitName];
+ GITRepo *itemAtIndex = [projectController objectInListAtIndex:indexPath.row];
+ cell.text = [itemAtIndex desc];
return cell;
}
View
8 iGitHub.xcodeproj/project.pbxproj
@@ -332,6 +332,7 @@
31F1DB5A10D57FD400AFEBEF /* CocoaGit */ = {
isa = PBXGroup;
children = (
+ 31F1DC6E10D5A54100AFEBEF /* Refs */,
31F1DBC710D5824600AFEBEF /* Packs */,
31F1DBB710D5822B00AFEBEF /* Stores */,
31F1DBA110D5820200AFEBEF /* Core */,
@@ -469,6 +470,13 @@
name = PackfileIndex;
sourceTree = "<group>";
};
+ 31F1DC6E10D5A54100AFEBEF /* Refs */ = {
+ isa = PBXGroup;
+ children = (
+ );
+ name = Refs;
+ sourceTree = "<group>";
+ };
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
View
1  main.m
@@ -3,6 +3,7 @@
*/
#import <UIKit/UIKit.h>
+#import "Git.h"
int main(int argc, char *argv[])
{
Please sign in to comment.
Something went wrong with that request. Please try again.