User Tools

Site Tools


findme:start

This is an old revision of the document!


Accessing file (12/08/09)

We can select cell in table and get file title. This delegate method will send httpRequest to get file contents. Here is delegate method.

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

      // this line to get selected cell by user
HistoryCell *cell = (HistoryCell *)[table cellForRowAtIndexPath:indexPath];

      // get contents of the cell
      History *hs = cell.historyView.history;
      // set a new url path to get contents of the file

NSString *path = hs.string;

NSString *newUrl = [[NSString alloc] init];
newUrl = [self.baseUrl stringByAppendingString:path];

HTTPRequest *httpRequest = [[HTTPRequest alloc] init];

  [httpRequest setDelegate:self selector:@selector(didReceiveFinished:)];
  // this line will try to connect to new url. After this line, methods we uploaded in 11/25/09 will execute. 
  [httpRequest requestUrl:newUrl];

}

I checked result in Debug console.

This is the contents of the .csv file. After this, we will implement authentication using public cookie.

Accessing file (12/04/09)

We tried to parse webpage efficiently, but we cannot find good way which use classes in Objective-C. So, we tried to study html in given webpage.

Code Text

Http body <!DOCTYPE HTML PUBLIC “-W3CDTD HTML 3.2 FinalEN”> <head> <title>Index of /iphone-project</title> </head> <body> <h1>Index of /iphone-project</h1> <table><tr><th><img src="/icons/blank.gif" alt="[ICO]"></th><th><a href="?C=N;O=D">Name</a></th><th><a href="?C=M;O=A">Last modified</a></th><th><a href="?C=S;O=A">Size</a></th><th><a href="?C=D;O=A">Description</a></th></tr><tr><th colspan="5"><hr></th></tr> <tr><td valign="top"><img src="/icons/back.gif" alt="[DIR]"></td><td><a href="/">Parent Directory</a> </td><td>&nbsp;</td><td align="right"> - </td></tr> <tr><td valign="top"><img src="/icons/unknown.gif" alt="[ ]"></td><td><a href="sample-xls-file.csv">sample-xls-file.csv</a> </td><td align="right">24-Sep-2009 16:54 </td><td align="right"> 63K</td></tr> <tr><td valign="top"><img src="/icons/unknown.gif" alt="[ ]"></td><td><a href="sample-xls-file.xls">sample-xls-file.xls</a> </td><td align="right">14-Sep-2009 23:40 </td><td align="right">276K</td></tr> <tr><th colspan="5"><hr></th></tr> </table> </body> } - This is the webpage showing file and directory lists. We found that “alt” variable determines type of the object. So, based on this http source, we made parsing method.

Here is method.

- (void) getFileNames:(NSString *)body {

      // body means above http body.
const char *httpbody = [body UTF8String];
char tmpPath[100];
NSString *path;
BOOL check = NO;
BOOL find = NO;
      
      //check all characters and get string we wanted.
      //only [DIR] or [   ] is acceptable to show lists.
for ( int i = 0 ; i < strlen(httpbody) ; i++ ) {
	if ( httpbody[i] == '[' )
		check = YES;
	else if ( httpbody[i] == ']' ) {
		check = NO;
	}
	else if ( check == YES ) {
		if ( httpbody[i] == 'D' )
			if ( httpbody[i+1] == 'I' )
				if ( httpbody[i+2] == 'R' )
					find = YES;
		
		if ( httpbody[i] == ' ' )
			if ( httpbody[i+1] == ' ' )
				if ( httpbody[i+2] == ' ' )
					find = YES;
	}
	else if ( find == YES && httpbody[i] == 'h' && httpbody[i+1] == 'r' && httpbody[i+2] == 'e' && httpbody[i+3] == 'f' ) {
		while ( httpbody[i-1] != '>' )
			i++;
		int j = 0;
		while ( httpbody[i] != '<' ) {
			tmpPath[j] = httpbody[i];
			i++, j++;
		}
		tmpPath[j] = '\0';
                      // new path to get file contents 
		path = [[NSString alloc] initWithCString:tmpPath];
		NSLog(@" pathsms : %@", path);
	
                      // this is filter to only show .csv files
		NSString *searchForMe = @".csv";
		NSRange range = [path rangeOfString : searchForMe];
		
		if ( range.location != NSNotFound ) {
                              // History is class we made to show file title in table
			History *hs = [[History alloc] init];
			hs.string = path;	
			[self.historyList addObject:hs];
		
			[hs.string release];
			[hs release];
		}
		//[hs release];
		//[table 
		find = NO;
	}
					
}
      // update table
[table reloadData];	

if ( [self.historyList count] > 0 ) {
	NSIndexPath *indexPath = [NSIndexPath indexPathForRow:[historyList count]-1 inSection:0];
	[table scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionNone animated:YES];
}

}

Using this method, we can finally show lists. After this method..

Accessing file (11/29/09)

Using given webpage : “https://www.cs.wisc.edu/iphone-project/”. Finally, we can get lists by connecting that page. First, we connected to this page by using NSURL classes. Iphone support http communication without web browser like safari in code. As I linked to apis in url loading system, There are delegate methods to connect to webpage. Here are codes:

- (BOOL)requestUrl:(NSString *)url {

  // first make request to send message to url 
  NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:url]
                                                         cachePolicy:NSURLRequestUseProtocolCachePolicy
                                                     timeoutInterval:5.0f];

  // using given url and request, try to connect
  NSURLConnection *connection = [[[NSURLConnection alloc] initWithRequest:request delegate:self] autorelease];
      
  // if connection is correct
  if(connection)
  {
      // initialize space which save data from response
      receivedData = [[NSMutableData alloc] init];
      return YES;
  }

  return NO;

}

Below methods are delegate methods. Those works during iphone tries to connect with specific url.

- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)aResponse {

  //just save response 
  self.response = aResponse;
NSArray *cookies;

}

This delegate method save data which is from web server.

- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {

if ( data ) {
      // this method can be called several times when data are sent from server in pieces. 
	[receivedData appendData:data];

}

}

This delegate method notify the situation when error occurs

- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error {

  NSLog(@"Error: %@", [error localizedDescription]);

}

When transfer data from server to client, this method is called to deal with given data.

- (void)connectionDidFinishLoading:(NSURLConnection *)connection {

  // convert data to NSString for convenience.
  result = [[NSString alloc] initWithData:receivedData encoding:NSUTF8StringEncoding];
  
  // send converted data to specific method which manipulates data.
  if(target)
  {
      [target performSelector:selector withObject:result];
  }

}

- (void)setDelegate:(id)aTarget selector:(SEL)aSelector {

  // set selector which will be used after connection.
  self.target = aTarget;
  self.selector = aSelector;

}

After this methods, we can get information of webpage : “https://www.cs.wisc.edu/iphone-project/. We will going to get parse data to get lists.

Accessing file (11/25/09)

Before authentication, we've tried to save file using given webpage : “https://www.cs.wisc.edu/iphone-project/ Of course, we have to access private webpage after verification. First, we wanted to implement download file. So, first we made temporary design and check result using debug console where programmer notify messages by using NSLOG method. This is first one. This includes one table and three text boxes. User will insert id and password and url where .csv files are uploaded. After user push the button whose title is “Get Lists”, table shows .csv and directories.

Accessing file (11/16/09)

We've found a website for implementing url loading by using cookies. Detail document is at this page.

http://developer.apple.com/iphone/library/documentation/Cocoa/Conceptual/URLLoadingSystem/URLLoadingSystem.html

We're going to find a way to access the cs server where we get a permission using cookie after identification.

Budget Chart (11/10/09)

We've made a sample code to practice using core-plot libraries. Below codes are core part of the sample source.

Budget Chart (11/08/09)

We've found a graphing library called core-plot. We should figure out managing this library. Detail document is at this website Core-Plot

Budget Chart (10/23/09)

I have found some interesting softwares relating to our project. Maybe we can use that to figure out what we should do with the graphical interface tomorrow when we meet.

Create QRcode (10/12/09)

We can create the QRcode from this website Kawa.com

1. As you can see below the image, you need to select “Content type” to “Text”.

Also, this QR code contains some information with typical format

“Google calendar ID:Department:Name” Each information is separated by colon ”:”

2. This is an example of generating QR-code

Screenshots of FindMe

1. This is the first starting screen of the application. The IPhone camera can be used to take a picture of the barcode or you have the option to choose from your saved files.


2. When the barcode gets decoded, the information decoded in the barcode pops up.


3. If you click “Open” button from step 2, the individual's one day's schedule will show up in the following format.


4. For more information about the schedule, one can click on the “Week” button to see the one week amount of schedule for this person.


5. hen the “E-Mail” button is clicked, the following pop up will show up. If you click ok, the current applcation will close down, and the IPhone's email application will run.


6. As shoon below, the email applcation will have the email address of the barcode's owner.

findme/start.1260519432.txt.gz · Last modified: 2009/12/11 02:17 by heedu