Commits

Mathieu Van der haegen  committed 4f29472

Initial commit

  • Participants

Comments (0)

Files changed (135)

File .DS_Store

Binary file added.
+ikraigslist-ios-app

File .idea/encodings.xml

+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false" />
+</project>
+

File .idea/ikraigslist-ios-app.iml

+<?xml version="1.0" encoding="UTF-8"?>
+<module type="PYTHON_MODULE" version="4">
+  <component name="NewModuleRootManager">
+    <content url="file://$MODULE_DIR$" />
+    <orderEntry type="inheritedJdk" />
+    <orderEntry type="sourceFolder" forTests="false" />
+  </component>
+</module>
+

File .idea/misc.xml

+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="DependencyValidationManager">
+    <option name="SKIP_IMPORT_STATEMENTS" value="false" />
+  </component>
+  <component name="Git.Settings">
+    <option name="CHECKOUT_INCLUDE_TAGS" value="false" />
+    <option name="UPDATE_CHANGES_POLICY" value="STASH" />
+  </component>
+  <component name="ProjectRootManager" version="2" project-jdk-name="Python 2.6.1 (/System/Library/Frameworks/Python.framework/Versions/2.6/bin/python)" project-jdk-type="Python SDK" />
+</project>
+

File .idea/modules.xml

+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="ProjectModuleManager">
+    <modules>
+      <module fileurl="file://$PROJECT_DIR$/.idea/ikraigslist-ios-app.iml" filepath="$PROJECT_DIR$/.idea/ikraigslist-ios-app.iml" />
+    </modules>
+  </component>
+</project>
+

File .idea/vcs.xml

+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="VcsDirectoryMappings">
+    <mapping directory="" vcs="" />
+    <mapping directory="$PROJECT_DIR$" vcs="hg4idea" />
+  </component>
+</project>
+

File .idea/workspace.xml

+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="ChangeListManager">
+    <list default="true" id="ec02c075-0c41-49d1-9e8e-6581104a0c58" name="Default" comment="">
+      <change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/.idea/ikraigslist-ios-app.iml" />
+      <change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/.idea/encodings.xml" />
+      <change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/.idea/misc.xml" />
+      <change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/.idea/modules.xml" />
+      <change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/.idea/vcs.xml" />
+    </list>
+    <ignored path="ikraigslist-ios-app.iws" />
+    <ignored path=".idea/workspace.xml" />
+    <option name="TRACKING_ENABLED" value="true" />
+    <option name="SHOW_DIALOG" value="false" />
+    <option name="HIGHLIGHT_CONFLICTS" value="true" />
+    <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
+    <option name="LAST_RESOLUTION" value="IGNORE" />
+  </component>
+  <component name="ChangesViewManager" flattened_view="true" show_ignored="false" />
+  <component name="CreatePatchCommitExecutor">
+    <option name="PATCH_PATH" value="" />
+    <option name="REVERSE_PATCH" value="false" />
+  </component>
+  <component name="DaemonCodeAnalyzer">
+    <disable_hints />
+  </component>
+  <component name="FavoritesManager">
+    <favorites_list name="ikraigslist-ios-app" />
+  </component>
+  <component name="ProjectLevelVcsManager">
+    <OptionsSetting value="true" id="Add" />
+    <OptionsSetting value="true" id="Remove" />
+    <OptionsSetting value="true" id="Checkout" />
+    <OptionsSetting value="true" id="Update" />
+    <OptionsSetting value="true" id="Status" />
+    <OptionsSetting value="true" id="Edit" />
+    <ConfirmationsSetting value="0" id="Add" />
+    <ConfirmationsSetting value="0" id="Remove" />
+  </component>
+  <component name="ProjectReloadState">
+    <option name="STATE" value="0" />
+  </component>
+  <component name="ProjectView">
+    <navigator currentView="ProjectPane" proportions="" version="1" splitterProportion="0.5">
+      <flattenPackages />
+      <showMembers />
+      <showModules />
+      <showLibraryContents />
+      <hideEmptyPackages />
+      <abbreviatePackageNames />
+      <autoscrollToSource />
+      <autoscrollFromSource />
+      <sortByType />
+    </navigator>
+    <panes>
+      <pane id="Scope" />
+      <pane id="Favorites" />
+      <pane id="ProjectPane">
+        <subPane>
+          <PATH>
+            <PATH_ELEMENT>
+              <option name="myItemId" value="ikraigslist-ios-app" />
+              <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
+            </PATH_ELEMENT>
+          </PATH>
+        </subPane>
+      </pane>
+    </panes>
+  </component>
+  <component name="PropertiesComponent">
+    <property name="options.splitter.main.proportions" value="0.3" />
+    <property name="WebServerToolWindowFactoryState" value="true" />
+    <property name="options.lastSelected" value="reference.settingsdialog.IDE.editor.colors" />
+    <property name="options.splitter.details.proportions" value="0.2" />
+    <property name="options.searchVisible" value="true" />
+  </component>
+  <component name="RunManager">
+    <list size="0" />
+  </component>
+  <component name="ShelveChangesManager" show_recycled="false" />
+  <component name="SvnConfiguration" maxAnnotateRevisions="500">
+    <option name="USER" value="" />
+    <option name="PASSWORD" value="" />
+    <option name="LAST_MERGED_REVISION" />
+    <option name="UPDATE_RUN_STATUS" value="false" />
+    <option name="MERGE_DRY_RUN" value="false" />
+    <option name="MERGE_DIFF_USE_ANCESTRY" value="true" />
+    <option name="UPDATE_LOCK_ON_DEMAND" value="false" />
+    <option name="IGNORE_SPACES_IN_MERGE" value="false" />
+    <option name="DETECT_NESTED_COPIES" value="true" />
+    <option name="CHECK_NESTED_FOR_QUICK_MERGE" value="false" />
+    <option name="IGNORE_SPACES_IN_ANNOTATE" value="true" />
+    <option name="SHOW_MERGE_SOURCES_IN_ANNOTATE" value="true" />
+    <myIsUseDefaultProxy>false</myIsUseDefaultProxy>
+  </component>
+  <component name="TaskManager">
+    <task active="true" id="Default" summary="Default task">
+      <created>1308819969215</created>
+      <updated>1308819969215</updated>
+    </task>
+    <servers />
+  </component>
+  <component name="ToolWindowManager">
+    <frame x="-59" y="1024" width="1440" height="848" extended-state="6" />
+    <editor active="false" />
+    <layout>
+      <window_info id="Changes" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
+      <window_info id="CSS-X-Fire" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
+      <window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
+      <window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="1" side_tool="true" content_ui="tabs" />
+      <window_info id="Remote Host" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
+      <window_info id="Dependency Viewer" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
+      <window_info id="Project" active="true" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.24946082" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
+      <window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.4" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
+      <window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
+      <window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
+      <window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
+      <window_info id="Message" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
+      <window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
+      <window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
+      <window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.4" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
+      <window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.4" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
+      <window_info id="Hierarchy" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="2" side_tool="false" content_ui="combo" />
+    </layout>
+  </component>
+  <component name="VcsManagerConfiguration">
+    <option name="OFFER_MOVE_TO_ANOTHER_CHANGELIST_ON_PARTIAL_COMMIT" value="true" />
+    <option name="CHECK_CODE_SMELLS_BEFORE_PROJECT_COMMIT" value="true" />
+    <option name="PERFORM_UPDATE_IN_BACKGROUND" value="true" />
+    <option name="PERFORM_COMMIT_IN_BACKGROUND" value="true" />
+    <option name="PERFORM_EDIT_IN_BACKGROUND" value="true" />
+    <option name="PERFORM_CHECKOUT_IN_BACKGROUND" value="true" />
+    <option name="PERFORM_ADD_REMOVE_IN_BACKGROUND" value="true" />
+    <option name="PERFORM_ROLLBACK_IN_BACKGROUND" value="false" />
+    <option name="CHECK_LOCALLY_CHANGED_CONFLICTS_IN_BACKGROUND" value="false" />
+    <option name="ENABLE_BACKGROUND_PROCESSES" value="false" />
+    <option name="CHANGED_ON_SERVER_INTERVAL" value="60" />
+    <option name="SHOW_ONLY_CHANGED_IN_SELECTION_DIFF" value="true" />
+    <option name="FORCE_NON_EMPTY_COMMENT" value="false" />
+    <option name="LAST_COMMIT_MESSAGE" />
+    <option name="MAKE_NEW_CHANGELIST_ACTIVE" value="true" />
+    <option name="OPTIMIZE_IMPORTS_BEFORE_PROJECT_COMMIT" value="false" />
+    <option name="CHECK_FILES_UP_TO_DATE_BEFORE_COMMIT" value="false" />
+    <option name="REFORMAT_BEFORE_PROJECT_COMMIT" value="false" />
+    <option name="REFORMAT_BEFORE_FILE_COMMIT" value="false" />
+    <option name="FILE_HISTORY_DIALOG_COMMENTS_SPLITTER_PROPORTION" value="0.8" />
+    <option name="FILE_HISTORY_DIALOG_SPLITTER_PROPORTION" value="0.5" />
+    <option name="ACTIVE_VCS_NAME" />
+    <option name="UPDATE_GROUP_BY_PACKAGES" value="false" />
+    <option name="UPDATE_GROUP_BY_CHANGELIST" value="false" />
+    <option name="SHOW_FILE_HISTORY_AS_TREE" value="false" />
+    <option name="FILE_HISTORY_SPLITTER_PROPORTION" value="0.6" />
+  </component>
+  <component name="XDebuggerManager">
+    <breakpoint-manager />
+  </component>
+</project>
+

File ikraigslist/.DS_Store

Binary file added.

File ikraigslist/Classes/AppDelegateMethods.h

+//
+//  AppDelegateMethods.h
+//  CraigsList
+//
+//  Created by Mathieu Van der Haegen on 07/12/08.
+//  Copyright 2008 __MyCompanyName__. All rights reserved.
+//
+
+@class CraigSimpleItem, CraigsListAppDelegate;
+
+@interface CraigsListAppDelegate (AppDelegateMethods)
+
+- (void)showItemInfo:(CraigSimpleItem *)dictionary;
+- (void)addToItemsList:(CraigSimpleItem *)eq;
+
+@end

File ikraigslist/Classes/AppParams.h

+//
+//  AppParams.h
+//  CraigsList
+//
+//  Created by Mathieu Van der Haegen on 21/12/08.
+//  Copyright 2008 __MyCompanyName__. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+
+
+@interface AppParams : NSObject {
+	NSInteger numberItems;
+	NSString *locationName;
+	NSString *locationUrl;
+	NSInteger currentController;
+}
+
+@property (nonatomic,retain) NSString *locationName;
+@property (nonatomic,retain) NSString *locationUrl;
+@property NSInteger currentController;
+@property NSInteger numberItems;
+
+-(void) saveDB;
+@end

File ikraigslist/Classes/AppParams.m

+//
+//  AppParams.m
+//  CraigsList
+//
+//  Created by Mathieu Van der Haegen on 21/12/08.
+//  Copyright 2008 __MyCompanyName__. All rights reserved.
+//
+
+#import "AppParams.h"
+#import "DataManager.h"
+
+
+@implementation AppParams
+
+@synthesize locationUrl;
+@synthesize locationName;
+@synthesize numberItems;
+@synthesize currentController;
+
+-(id) init {
+	if (self = [super init]) {
+		NSString *tmp,*tmp2,*tmp3,*tmp4;
+		
+		tmp = [DataManager getValueForKey:@"default_location_name"];
+		tmp2 = [DataManager getValueForKey:@"default_location_url"];
+		
+		self.locationName=tmp;
+		self.locationUrl=tmp2;
+		
+		tmp3 = [DataManager getValueForKey:@"default_number_items"];
+		if (tmp3!=nil) {
+			self.numberItems = [tmp3 intValue];
+		} else {
+			self.numberItems=0;
+		}
+		
+		if (self.numberItems <25) {
+			self.numberItems=25;
+		}
+		
+		tmp4 = [DataManager getValueForKey:@"default_current_controller"];
+		if (tmp4!=nil) {
+			self.currentController = [tmp4 intValue];
+		}
+		
+		[tmp release];
+		[tmp2 release];
+		[tmp3 release];
+		[tmp4 release];
+		
+
+	}
+	return self;
+}
+
+-(void) saveDB {
+	if (locationUrl!=nil) {
+		[DataManager setValue:locationUrl forKey:@"default_location_url"];
+	}
+	if (locationName != nil) {
+		[DataManager setValue:locationName forKey:@"default_location_name"];
+	}
+	if (numberItems != 0) {
+		[DataManager setValue:[NSString stringWithFormat:@"%d",numberItems] forKey:@"default_number_items"];
+	}
+	
+	[DataManager setValue:[NSString stringWithFormat:@"%d",currentController] forKey:@"default_current_controller"];	
+
+}
+
+-(void) dealloc {
+	if (locationName) {
+		[locationName release];
+	}
+	if (locationUrl) {
+		[locationUrl release];
+	}
+	[super dealloc];
+}
+
+
+
+@end

File ikraigslist/Classes/BookMark.h

+//
+//  BookMark.h
+//  CraigsList
+//
+//  Created by Mathieu Van der Haegen on 12/12/08.
+//  Copyright 2008 __MyCompanyName__. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+#import "CraigDetailedItem.h"
+
+@interface BookMark : NSObject {
+	CraigDetailedItem *_savedItem;
+	NSString *_name;
+	NSUInteger _bookId;
+	NSString *_picturesString;
+	BOOL _picturesLoaded;
+}
+
+@property (nonatomic,retain) CraigDetailedItem *savedItem;
+@property (nonatomic,retain) NSString *name;
+@property NSUInteger bookId;
+@property (nonatomic,retain) NSString *picturesString;
+@property BOOL picturesLoaded;
+
+-(id) initWithItem:(CraigDetailedItem*) theitem;
+-(void) loadPictures;
+
+@end
+

File ikraigslist/Classes/BookMark.m

+//
+//  BookMark.m
+//  CraigsList
+//
+//  Created by Mathieu Van der Haegen on 12/12/08.
+//  Copyright 2008 __MyCompanyName__. All rights reserved.
+//
+
+#import "BookMark.h"
+#import "CraigDetailedItem.h"
+#import "DataManager.h";
+
+
+@implementation BookMark
+
+@synthesize savedItem = _savedItem;
+@synthesize picturesString = _picturesString;
+@synthesize picturesLoaded = _picturesLoaded;
+@synthesize name = _name;
+@synthesize bookId = _bookId;
+
+-(id) initWithItem:(CraigDetailedItem*) theitem {
+	if (self = [super init]) {
+		self.savedItem = theitem;
+		_picturesLoaded=NO;
+		_bookId=0;
+		_picturesString=nil;
+		_name=nil;
+	}
+	return self;
+	
+}
+
+-(void) loadPictures {
+	//NSLog(@"++++%@",_picturesString);
+	if (_picturesString != nil && _picturesString.length >0) {
+		NSArray *filenames =  [_picturesString componentsSeparatedByString:@"||"];
+		for (NSString* filename in filenames) {
+			[_savedItem.images addObject:[DataManager loadImage:filename]];
+		}
+		_picturesLoaded=YES;
+	} else {
+		_picturesLoaded=YES;
+	}
+}
+
+-(void) dealloc {
+	if (_picturesString) {
+		[_picturesString release];
+	}
+	
+	if(_name) {
+		[_name release];
+	}
+	if(_savedItem) {
+		[_savedItem release];
+	}
+	
+	
+	[super dealloc];
+}
+
+@end

File ikraigslist/Classes/BookmarksView.h

+//
+//  BookmarksView.h
+//  CraigsList
+//
+//  Created by Mathieu Van der Haegen on 12/12/08.
+//  Copyright 2008 __MyCompanyName__. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+
+@interface BookmarksView : UIView {
+
+}
+
+@end

File ikraigslist/Classes/BookmarksView.m

+//
+//  BookmarksView.m
+//  CraigsList
+//
+//  Created by Mathieu Van der Haegen on 12/12/08.
+//  Copyright 2008 __MyCompanyName__. All rights reserved.
+//
+
+#import "BookmarksView.h"
+
+
+@implementation BookmarksView
+
+
+
+@end

File ikraigslist/Classes/BookmarksViewController.h

+//
+//  BookmarksViewController.h
+//  CraigsList
+//
+//  Created by Mathieu Van der Haegen on 12/12/08.
+//  Copyright 2008 __MyCompanyName__. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+@interface BookmarksViewController :  UITableViewController<UITableViewDataSource,UITableViewDelegate> {
+	NSMutableArray *_bookmarks;
+}
+
+@property (nonatomic,retain) NSMutableArray * bookmarks;
+
+- (void)reload;
+
+@end

File ikraigslist/Classes/BookmarksViewController.m

+//
+//  BookmarksViewController.m
+//  CraigsList
+//
+//  Created by Mathieu Van der Haegen on 12/12/08.
+//  Copyright 2008 __MyCompanyName__. All rights reserved.
+//
+
+#import "BookmarksViewController.h"
+#import "SimpleCellWithDate.h"
+#import "BookMark.h"
+#import "DataManager.h"
+#import "Manager.h"
+
+static UIImage *tabImage = nil;
+
+@implementation BookmarksViewController
+
+@synthesize bookmarks=_bookmarks;
+
+- (id)initWithStyle:(UITableViewStyle)style  {
+	if (self = [super initWithStyle:style]) {
+		_bookmarks=nil;
+        self.tableView.delegate = self;
+        self.tableView.dataSource = self;
+        self.tableView.rowHeight = 40.0;
+        self.tableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
+        self.tableView.sectionHeaderHeight = 0;
+		tabImage = [[UIImage imageNamed:@"toolbar_bookmarks.png"] retain];
+		[self.tabBarItem initWithTitle:@"Saved ads" image:tabImage tag:0];
+		self.navigationItem.title=@"Saved ads";
+		self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] 
+												   initWithTitle:@"Edit" 
+												   style:UIBarButtonItemStylePlain 
+												   target:self 
+												   action:@selector(enterEditMode)] 
+												  autorelease]; 
+		[self reload];
+		
+	}
+	return self;
+}
+
+- (void) enterEditMode {
+	self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] 
+											   initWithTitle:@"Done" 
+											   style:UIBarButtonItemStylePlain 
+											   target:self 
+											   action:@selector(leaveEditMode)] 
+											  autorelease]; 
+	[self.tableView setEditing:YES animated:YES]; 
+	[self.tableView beginUpdates]; 
+	
+}
+
+-(void)leaveEditMode { 
+	self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] 
+											   initWithTitle:@"Edit" 
+											   style:UIBarButtonItemStylePlain 
+											   target:self 
+											   action:@selector(enterEditMode)] 
+											  autorelease]; 
+	[self.tableView endUpdates]; 
+	[self.tableView setEditing:NO animated:YES]; 
+}
+
+- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
+	return 1;
+}
+
+- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {	
+    NSUInteger count = [_bookmarks count];
+    return count;
+}
+
+- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
+{
+	[[Manager getDetail2] laadFromBookmark:[_bookmarks objectAtIndex:indexPath.row]];
+	[[self navigationController] pushViewController:[Manager getDetail2] animated:YES];
+}
+
+- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath {
+	return UITableViewCellEditingStyleDelete;
+}
+
+- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
+    
+	static NSString *MyIdentifier = @"MyIdentifier";
+    
+  	SimpleCellWithDate *cell = (SimpleCellWithDate *)[tableView dequeueReusableCellWithIdentifier:MyIdentifier];
+	if (cell == nil) {
+		cell = [[[SimpleCellWithDate alloc] initWithFrame:CGRectZero reuseIdentifier:MyIdentifier] autorelease];
+	}
+	
+	BookMark *b = [_bookmarks objectAtIndex:indexPath.row];
+	
+	[cell setTheText:[b name] andDate:[[[b savedItem] baseItem] date]];
+	
+	cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
+	
+	return cell;
+}
+
+-(void)tableView:(UITableView *)tableView  commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath 
+{ 
+	[DataManager deleteBookmark:[_bookmarks objectAtIndex:[indexPath row]]];
+	[_bookmarks removeObjectAtIndex:[indexPath row]]; 
+	[self.tableView reloadData]; 
+} 
+
+
+- (void)reload {
+	if (_bookmarks != nil) {
+		[_bookmarks removeAllObjects];
+		[_bookmarks release];
+	}
+	self.bookmarks = [DataManager getBookmarks];
+	[self.tableView reloadData];
+
+}
+
+
+
+@end

File ikraigslist/Classes/ConnectionManager.h

+//
+//  ConnectionManager.h
+//  CraigsList
+//
+//  Created by Mathieu Van der Haegen on 25/06/09.
+//  Copyright 2009 __MyCompanyName__. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+
+
+@interface ConnectionManager : NSObject {
+
+}
+
+
+- (NSString *) getStringFromString : (NSString *) theString;
+- (NSString *) getStringFromUrl : (NSURL *) theUrl;
+
+- (UIImage *) getImageFromString : (NSString *) theString;
+- (UIImage *) getImageFromUrl : (NSURL *) theUrl;
+
+
+@end

File ikraigslist/Classes/ConnectionManager.m

+//
+//  ConnectionManager.m
+//  CraigsList
+//
+//  Created by Mathieu Van der Haegen on 25/06/09.
+//  Copyright 2009 __MyCompanyName__. All rights reserved.
+//
+
+#import "ConnectionManager.h"
+
+
+@implementation ConnectionManager
+
+
+/*
+ NSError *err = nil;
+ NSURLRequest *myRequest = [ [NSURLRequest alloc] initWithURL:URL ];
+ NSData *data = [ NSURLConnection sendSynchronousRequest:myRequest returningResponse: nil error: &err ];
+ if (err != nil) {
+ NSLog(@"code : %d ,  desc: %@",[err code],[err localizedDescription]);
+ return;
+ }
+ 
+ NSString *theString = [[NSString alloc] initWithData: data encoding: NSASCIIStringEncoding ];
+ */
+
+
+- (NSString *) getStringFromString : (NSString *) theString {
+	
+	NSURL *url = [NSURL URLWithString:theString];
+	
+	return [self getStringFromUrl: url];
+	
+}
+
+- (NSString *) getStringFromUrl : (NSURL *) theUrl {
+	NSError *err=nil;
+	NSMutableURLRequest *req = [NSMutableURLRequest requestWithURL:theUrl];
+	NSData *data = [NSURLConnection sendSynchronousRequest:req returningResponse:nil error:&err]; 
+	
+	
+	if (data==nil) {
+		data = [NSURLConnection sendSynchronousRequest:req returningResponse:nil error:&err]; 
+		
+		if (data==nil) {
+			data = [NSURLConnection sendSynchronousRequest:req returningResponse:nil error:&err]; 
+			
+			if (data==nil) {
+				data = [NSURLConnection sendSynchronousRequest:req returningResponse:nil error:&err]; 
+			}
+		}
+		
+	}
+	
+	
+	
+	if (err != nil || data==nil) {
+		NSLog(@"code : %d ,  desc: %@",[err code],[err localizedDescription]);
+		return nil;
+	} else {
+		NSString *tmp = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding];;
+		return tmp;
+	}
+}
+
+- (UIImage *) getImageFromString : (NSString *) theString {
+	NSURL *url = [NSURL URLWithString:theString];
+	
+	return [self getImageFromUrl: url];
+}
+
+- (UIImage *) getImageFromUrl : (NSURL *) theUrl {
+	NSData *imageData = [NSData dataWithContentsOfURL:theUrl options:NSMappedRead error:nil];
+	UIImage *temp = [UIImage imageWithData:imageData];
+	if (temp == nil) {
+		temp = [UIImage imageWithData:[NSData dataWithContentsOfURL:theUrl]];
+		
+		if (temp == nil) {
+			temp = [UIImage imageWithData:[NSData dataWithContentsOfURL:theUrl]];
+		}
+	}
+	
+	return temp;
+}
+
+
+
+-(id) init {
+	return [super init];
+}
+
+
+- (void) dealloc {
+	[super dealloc];
+}
+
+@end

File ikraigslist/Classes/CraigDetailXMLReader.h

+//
+//  CraigDetailXMLReader.h
+//  CraigsList
+//
+//  Created by Mathieu Van der Haegen on 17/12/08.
+//  Copyright 2008 __MyCompanyName__. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+#include <libxml/HTMLparser.h>
+#import "CraigDetailedItem.h"
+
+@interface CraigDetailXMLReader : NSObject {
+	htmlDocPtr _doc;
+	CraigDetailedItem *_item;
+	
+}
+
+- (void) parseFromObject:(CraigDetailedItem *) item;
+@end

File ikraigslist/Classes/CraigDetailXMLReader.m

+//
+//  CraigDetailXMLReader.m
+//  CraigsList
+//
+//  Created by Mathieu Van der Haegen on 17/12/08.
+//  Copyright 2008 __MyCompanyName__. All rights reserved.
+//
+
+#import "CraigDetailXMLReader.h"
+#import "DetailView.h"
+#import "Manager.h"
+#import "DataManager.h"
+#include <libxml/parser.h>
+#include <libxml/tree.h>
+#include <libxml/HTMLparser.h>
+#include <libxml/HTMLtree.h>
+#include <libxml/xpath.h>
+#include <libxml/xpathInternals.h>
+
+@interface CraigDetailXMLReader()
+- (void) parseBody;
+- (void) parseImages;
+- (void) parseEmail;
+- (void) parseMap;
+
+@end
+
+
+@implementation CraigDetailXMLReader
+
+- (void) parseBody {
+	
+	xmlNodeSetPtr nodes = NULL;
+	xmlNodePtr root_element = NULL;
+	xmlXPathContextPtr xpathCtx = NULL; 
+    xmlXPathObjectPtr xpathObj = NULL; 
+	xmlNodePtr cur = NULL;
+	xmlBufferPtr bufptr = NULL;
+	NSString* conte;
+	int size=0,i=0;
+	
+	root_element = xmlDocGetRootElement(_doc);
+	
+	xpathCtx = xmlXPathNewContext(_doc);
+    if(xpathCtx != NULL) {
+		
+		xpathObj = xmlXPathEvalExpression("/html/body/div[@id='userbody']", xpathCtx);
+		
+		if (xpathObj == NULL) {
+			xmlXPathFreeContext(xpathCtx);
+			return;
+		}
+		
+		nodes = xpathObj->nodesetval;
+	
+		size = (nodes) ? nodes->nodeNr : 0;
+		
+		if (size == 1) {
+			if(nodes->nodeTab[0]->type == XML_ELEMENT_NODE) {
+				cur = nodes->nodeTab[0];
+				
+				bufptr = xmlBufferCreate();
+				
+				i = htmlNodeDump(bufptr,_doc,cur);
+				
+				const char* aaa = xmlBufferContent(bufptr);
+				
+				conte = [NSString stringWithUTF8String:aaa];
+				
+				
+				[_item setBodyContent:conte];
+				
+				xmlBufferFree(bufptr);
+			}
+		} else {
+			[_item setBodyContent:@"<font color='#FF0000' size='18'><b>Not found</b></font>"];
+		}
+		xmlXPathFreeContext(xpathCtx);
+		xmlXPathFreeObject(xpathObj);
+		
+		
+		//NSLog(@"%@", [_item bodyContent]);
+	}
+}
+
+- (void) parseImages {
+	xmlXPathContextPtr xpathCtx = NULL; 
+    xmlXPathObjectPtr xpathObj = NULL; 
+	xmlNodePtr cur = NULL;
+	xmlNodeSetPtr nodes = NULL;
+	int size=0,i=0;
+	
+	xpathCtx = xmlXPathNewContext(_doc);
+	
+	if(xpathCtx != NULL) {
+		xpathObj = xmlXPathEvalExpression("//img/@src", xpathCtx);
+		if (xpathObj != NULL) {
+			nodes = xpathObj->nodesetval;
+			
+			size = (nodes) ? nodes->nodeNr : 0;
+			
+			if (size > 0) {
+				[[[Manager getDetail] buttons] setEnabled:YES forSegmentAtIndex:2];
+				for (i=0;i<size;i++) {
+					if(nodes->nodeTab[i]->type == XML_ATTRIBUTE_NODE) {
+						cur = nodes->nodeTab[i];
+						
+						if( cur->children->content) {
+							//here we got the image name / url : cur->children->content
+							[_item addImage: [NSString stringWithUTF8String:cur->children->content]];
+						}
+					}
+				}
+			}
+			xmlXPathFreeObject(xpathObj);
+		}
+		xmlXPathFreeContext(xpathCtx);
+	}
+	
+	
+}
+
+- (void) parseEmail {
+	xmlXPathContextPtr xpathCtx = NULL; 
+    xmlXPathObjectPtr xpathObj = NULL; 
+	xmlNodePtr cur = NULL;
+	xmlNodeSetPtr nodes = NULL;
+	int size=0;
+	
+	xpathCtx = xmlXPathNewContext(_doc);
+	
+	if(xpathCtx != NULL) {
+		xpathObj = xmlXPathEvalExpression("/html/body//a[starts-with(@href, 'mailto:')]", xpathCtx);
+		if (xpathObj != NULL) {
+			nodes = xpathObj->nodesetval;
+			
+			size = (nodes) ? nodes->nodeNr : 0;
+			
+			if (size == 1) {
+				if(nodes->nodeTab[0]->type == XML_ELEMENT_NODE) {
+					cur = nodes->nodeTab[0];
+					if (cur->properties->children->content) {
+						NSString* tmp = [NSString stringWithUTF8String:cur->properties->children->content];
+						_item.emailLink =tmp;
+						[[[Manager getDetail] buttons] setEnabled:YES forSegmentAtIndex:1];
+					}
+				}
+			}
+			xmlXPathFreeObject(xpathObj);
+		}
+		xmlXPathFreeContext(xpathCtx);
+	}
+}
+
+- (void) parseMap {
+	//[[[Manager getDetail] buttons] setEnabled:YES forSegmentAtIndex:1];
+	
+}
+
+- (void) parseFromObject:(CraigDetailedItem *) item {
+	_doc= NULL;
+	_item = item;
+	
+	//NSLog(@"%@",[item htmlContent]);
+	
+	[(UIWebView*) [[Manager getDetail] view] loadHTMLString:[DataManager getLoadingHtml] baseURL:[NSURL fileURLWithPath:[DataManager getBundleDirectory]]];
+
+	//NSLog([DataManager getLoadingHtml]);
+	
+	_doc= htmlParseDoc([[item htmlContent] UTF8String],[@"UTF-8" UTF8String]);
+	
+	if (_doc == NULL) {
+        NSLog(@"error: could not parse file\n");
+		[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
+		return;
+    }
+	
+
+	[self parseBody];
+	[self parseEmail];
+	[self parseImages];
+	[self parseMap];
+	
+	//here we should replace the images by copies in temp dir
+	NSArray *images = item.images;
+	int cnt=0;
+	
+	if ( [images count] > 0 ) {
+		for ( UIImage *im in images) {
+			NSString* tmp = [DataManager writeImageTemp:im];
+			NSString* oldName = [item.imagesUrls objectAtIndex:cnt];
+			
+			cnt++;
+			
+			if (tmp!=nil && oldName!=nil) {
+				[item.imagesUrls replaceObjectAtIndex:(cnt-1) withObject:tmp];
+				item.bodyContent = [[item bodyContent] stringByReplacingOccurrencesOfString: oldName withString: tmp]; //maybe add something here
+			}
+			
+			
+		}
+	}
+	
+	//NSLog([DataManager getDocumentDirectory]);
+	
+	//NSLog([DataManager getTempDirectory]);
+	
+	//NSLog([_item bodyContent]);
+	
+	[(UIWebView*) [[Manager getDetail] view] loadHTMLString:[_item bodyContent] baseURL:[NSURL fileURLWithPath:[DataManager getTempDirectory]]];
+	[[[Manager getDetail] buttons] setEnabled:YES forSegmentAtIndex:0];
+	
+	xmlFreeDoc(_doc);
+	[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
+	
+}
+@end

File ikraigslist/Classes/CraigDetailedItem.h

+//
+//  CraigDetailedItem.h
+//  CraigsList
+//
+//  Created by Mathieu Van der Haegen on 22/12/08.
+//  Copyright 2008 __MyCompanyName__. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+#import "CraigSimpleItem.h"
+
+
+@interface CraigDetailedItem : NSObject {
+	CraigSimpleItem *_baseItem;
+	NSString *_emailLink;
+	NSString *_mapLink;
+	NSMutableArray  *_images;
+	NSMutableArray *_imagesUrls;
+	NSString *_htmlContent;
+	NSString *_bodyContent;
+	
+	int _imagesCount;
+	BOOL _loaded;
+}
+
+@property (nonatomic,retain) CraigSimpleItem *baseItem;
+@property (nonatomic,retain) NSString *emailLink;
+@property (nonatomic,retain) NSString *mapLink;
+@property (nonatomic,retain) NSMutableArray *images;
+@property (nonatomic,retain) NSMutableArray *imagesUrls;
+@property (nonatomic,retain) NSString *htmlContent;
+@property (nonatomic,retain) NSString *bodyContent;
+@property int imagesCount;
+@property BOOL loaded;
+
+
+- (void) addImage:(NSString *) imageurl;
+-(id) initWithBase:(CraigSimpleItem*) thebase;
+- (void) loadMe;
+@end

File ikraigslist/Classes/CraigDetailedItem.m

+//
+//  CraigDetailedItem.m
+//  CraigsList
+//
+//  Created by Mathieu Van der Haegen on 22/12/08.
+//  Copyright 2008 __MyCompanyName__. All rights reserved.
+//
+
+#import "CraigDetailedItem.h"
+#import "CraigDetailXMLReader.h"
+#import "ConnectionManager.h"
+
+@interface CraigDetailedItem()
+- (void) parse;
+
+@end
+
+
+
+@implementation CraigDetailedItem
+
+@synthesize images = _images;
+@synthesize imagesUrls = _imagesUrls;
+@synthesize imagesCount = _imagesCount;
+@synthesize htmlContent = _htmlContent;
+@synthesize bodyContent = _bodyContent;
+@synthesize emailLink = _emailLink;
+@synthesize mapLink = _mapLink;
+@synthesize baseItem = _baseItem;
+@synthesize loaded = _loaded;
+
+
+-(id) initWithBase:(CraigSimpleItem*) thebase {
+	if (self = [super init]) {
+		self.baseItem = thebase;
+		_images = [[NSMutableArray alloc] init];
+		_imagesUrls = [[NSMutableArray alloc] init];
+		_loaded=NO;
+		_htmlContent=nil;
+		_emailLink=nil;
+		_mapLink=nil;
+	}
+	return self;
+}
+
+-(id) init {
+	if (self = [super init]) {
+		_images = [[NSMutableArray alloc] init];
+		_imagesUrls = [[NSMutableArray alloc] init];
+		_loaded=NO;
+		_htmlContent=nil;
+		_emailLink=nil;
+		_mapLink=nil;
+		_baseItem=nil;
+	}
+	return self;
+}
+
+- (void) addImage:(NSString *) imageurl {
+	//here we got the image
+	ConnectionManager * cm = [[ConnectionManager alloc] init];
+	UIImage *temp = [cm getImageFromString:imageurl];
+	[cm release];
+	
+	if (temp != nil) {
+		[_images addObject:temp];
+		[_imagesUrls addObject:imageurl];
+		_imagesCount++;
+	}
+}
+
+- (void) parse {
+	NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+	
+	CraigDetailXMLReader *reader = [[[CraigDetailXMLReader alloc] init] autorelease];
+	[reader parseFromObject:self];
+	[pool drain];
+	
+	_loaded=YES;
+}
+
+- (void) loadMe {
+	if (!_loaded) {
+		
+		if (_htmlContent) {
+			[_htmlContent release];
+		}
+		
+		ConnectionManager * cm = [[ConnectionManager alloc] init];
+		
+		if (_htmlContent) {
+			[_htmlContent release];
+			
+		}
+		_htmlContent = nil;
+		_htmlContent = [cm getStringFromString: _baseItem.directlink];
+		
+		[cm release];
+		if (_htmlContent == nil) {
+			return;
+		}
+		
+		[NSThread detachNewThreadSelector:@selector(parse) toTarget:self withObject:nil];
+	}
+}
+
+- (void) dealloc {
+	if (_baseItem) {
+		[_baseItem release];
+	}
+	if (_emailLink) {
+		[_emailLink release];
+	}
+	if (_mapLink) {
+		[_mapLink release];
+	}
+	if (_images) {
+		[_images release];
+	}
+	if (_imagesUrls) {
+		[_imagesUrls release];
+	}
+	if (_htmlContent) {
+		[_htmlContent release];
+	}
+	if (_bodyContent) {
+		[_bodyContent release];
+	}
+	[super dealloc];
+}
+
+@end

File ikraigslist/Classes/CraigSectionXMLReader.h

+//
+//  CraigSectionXMLReader.h
+//  CraigsList
+//
+//  Created by Mathieu Van der Haegen on 07/12/08.
+//  Copyright 2008 __MyCompanyName__. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+#import "CraigSimpleItem.h"
+
+
+@interface CraigSectionXMLReader : NSObject {
+
+	
+@private        
+    CraigSimpleItem *_currentItemObject;
+	NSString *_currentItemDate;
+}
+
+@property (nonatomic, retain) CraigSimpleItem *currentItemObject;
+@property (nonatomic, retain) NSString *currentItemDate;
+
+- (void)parseXMLFileAtURL:(NSURL *)URL parseError:(NSError **)error;
+
+@end

File ikraigslist/Classes/CraigSectionXMLReader.m

+//
+//  CraigSectionXMLReader.m
+//  CraigsList
+//
+//  Created by Mathieu Van der Haegen on 07/12/08.
+//  Copyright 2008 __MyCompanyName__. All rights reserved.
+//
+
+#import "CraigSectionXMLReader.h"
+#import "Manager.h"
+#import "ConnectionManager.h"
+
+#include <libxml/parser.h>
+#include <libxml/tree.h>
+#include <libxml/HTMLparser.h>
+#include <libxml/xpath.h>
+#include <libxml/xpathInternals.h>
+
+
+
+
+
+@implementation CraigSectionXMLReader
+
+@synthesize currentItemObject = _currentItemObject;
+@synthesize currentItemDate = _currentItemDate;
+
+
+// Limit the number of parsed earthquakes to 50. Otherwise the application runs very slowly on the device.
+#define MAX_ITEMS 50
+
+
+
+
+- (void) printElements: (xmlNodePtr) cur_node {
+	if (cur_node && cur_node->type == XML_ELEMENT_NODE) {
+		
+		//NSLog(@"node type: Element, name: %@\n", [NSString stringWithUTF8String:cur_node->name]);
+		
+		[self printElements:cur_node->children];
+		
+	}
+	
+}
+
+- (void)parseXMLFileAtURL:(NSURL *)URL parseError:(NSError **)error
+{	
+	
+	htmlDocPtr doc= NULL;
+    xmlNodePtr root_element = NULL;
+	xmlXPathContextPtr xpathCtx; 
+    xmlXPathObjectPtr xpathObj; 
+	int itemsCount=1;
+	int maxItems = [[Manager appParams] numberItems];
+	
+	_currentItemObject=nil;
+	_currentItemDate=nil;
+	
+	ConnectionManager * cm = [[ConnectionManager alloc] init]; //:[[[ConnectionManager alloc] init] autorelease];
+	NSString *theString = [cm getStringFromUrl:URL];
+	[cm release];
+		
+	
+	if (theString == nil) {
+		return;
+	}
+	
+	NSRange tmp = [theString rangeOfString:@"Nothing found for that search"];
+	
+	if (tmp.location != NSNotFound) {
+		UIAlertView *baseAlert = [[UIAlertView alloc] 
+								  initWithTitle:@"Attention"message:@"No results found for this search" 
+								  delegate:nil cancelButtonTitle:nil 
+								  otherButtonTitles:@"OK", nil]; 
+		
+		[baseAlert show];
+		[theString release];
+		[baseAlert release];
+		
+		[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
+		return;
+		
+	}
+		
+		
+	
+	doc= htmlParseDoc([theString UTF8String],[@"UTF-8" UTF8String]);
+	[theString release];
+	
+	if (doc == NULL) {
+        NSLog(@"error: could not parse file\n");
+    }
+	
+	root_element = xmlDocGetRootElement(doc);
+	
+	xpathCtx = xmlXPathNewContext(doc);
+    if(xpathCtx != NULL) {
+		
+		xpathObj = xmlXPathEvalExpression("/html/body/blockquote/p[not(@align)]/descendant-or-self::* | /html/body/blockquote/h4", xpathCtx);
+
+		if (xpathObj == NULL) {
+			xmlXPathFreeContext(xpathCtx);
+			[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
+			return;
+		}
+		xmlNodeSetPtr nodes = xpathObj->nodesetval;
+		xmlNodePtr cur;
+		int size,i;
+		
+		
+			
+		size = (nodes) ? nodes->nodeNr : 0;
+		
+		
+		for(i = 0; i < size; ++i) {
+			if(nodes->nodeTab[i]->type == XML_ELEMENT_NODE) {
+				cur = nodes->nodeTab[i];
+				if(!cur->ns) { 
+					if (cur->name && strcmp(cur->name,"p")==0) {
+						if( self.currentItemObject) {
+							itemsCount++;
+							[[Manager getHome]  performSelectorOnMainThread:@selector(addToItemsList:) withObject:self.currentItemObject waitUntilDone:YES];
+							//[(id)[[UIApplication sharedApplication] delegate] performSelectorOnMainThread:@selector(addToItemsList:) withObject:self.currentItemObject waitUntilDone:YES];
+							if (itemsCount > maxItems) {
+								break;
+							}
+							[_currentItemObject release];
+						}
+						
+						self.currentItemObject = [[CraigSimpleItem alloc] init];
+						
+						if (cur->children->content) {
+							NSString *tmp = [NSString stringWithFormat:@"%s",cur->children->content];
+							self.currentItemObject.date = [tmp substringToIndex: [tmp length]-2];
+						} else if (self.currentItemDate) {
+							self.currentItemObject.date = self.currentItemDate; 
+						}
+						
+					} else if (cur->name && strcmp(cur->name,"a")==0) {
+						
+						if (cur->properties->children->content) {
+							NSString *temp = [NSString stringWithUTF8String:cur->properties->children->content];
+							//quickfix
+							if ([temp characterAtIndex:(0)] == '/') {
+								temp = [temp substringFromIndex:(1)];
+							}
+							
+							
+							
+							if ([temp length]>5) {
+								
+								NSRange trange = [temp rangeOfString:[[Manager appParams] locationUrl]];
+								
+								if (trange.location == NSNotFound) {
+									self.currentItemObject.directlink = [NSString stringWithFormat:@"%@%@",[[Manager appParams] locationUrl],temp];
+								} else {
+									self.currentItemObject.directlink = [NSString stringWithFormat:@"%@",temp];
+								}
+								
+								if (cur->children->content) {
+									self.currentItemObject.title = [NSString stringWithFormat:@"%s",cur->children->content];
+								}
+							}
+							
+						}
+					} else if (cur->name && strcmp(cur->name,"font")==0) {
+						if (cur->children->content) {
+							self.currentItemObject.location = [NSString stringWithFormat:@"%s",cur->children->content];
+						}
+					} else if (cur->name && strcmp(cur->name,"span")==0) {
+						self.currentItemObject.hasPics=TRUE;
+					} else if (cur->name && strcmp(cur->name,"h4")==0) {
+						if (cur->children->content) {
+							self.currentItemDate = [NSString stringWithFormat:@"%s",(cur->children->content+4*sizeof(char))];
+						}
+					}
+				}
+			}
+		}
+		
+		
+		
+		if (size!=0) {
+			if( self.currentItemObject!=nil) {
+				[[Manager getHome]  performSelectorOnMainThread:@selector(addToItemsList:) withObject:self.currentItemObject waitUntilDone:YES];
+				[_currentItemObject release];
+				//[(id)[[UIApplication sharedApplication] delegate] performSelectorOnMainThread:@selector(addToItemsList:) withObject:self.currentItemObject waitUntilDone:YES];
+			}			
+			[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
+			[[Manager getHome] performSelectorOnMainThread:@selector(reloadTable) withObject:nil waitUntilDone:YES];
+			//[(id)[[UIApplication sharedApplication] delegate] performSelectorOnMainThread:@selector(reloadTable) withObject:nil waitUntilDone:YES];
+		}
+		
+
+		xmlXPathFreeContext(xpathCtx);
+		xmlXPathFreeObject(xpathObj);
+	}
+
+	
+	
+}
+
+- (void) dealloc {
+	if (_currentItemObject) {
+		[_currentItemObject release];
+	}
+	
+	if (_currentItemDate) {
+		[_currentItemDate release];
+	}
+	
+	[super dealloc];
+}
+
+
+
+@end

File ikraigslist/Classes/CraigSimpleItem.h

+//
+//  CraigItem.h
+//  CraigsList
+//
+//  Created by Mathieu Van der Haegen on 07/12/08.
+//  Copyright 2008 __MyCompanyName__. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+
+@interface CraigSimpleItem : NSObject {
+
+@private    
+	NSString *_title;       
+	NSString *_location;    
+	NSString *_directlink;
+	NSString *_date;
+	BOOL _hasPics;
+}
+
+@property (nonatomic, retain) NSString *title;       
+@property (nonatomic, retain) NSString *location;    
+@property (nonatomic, retain) NSString *directlink;	
+@property (nonatomic, retain) NSString *date;
+
+@property BOOL hasPics;
+
+
+@end

File ikraigslist/Classes/CraigSimpleItem.m

+//
+//  CraigItem.m
+//  CraigsList
+//
+//  Created by Mathieu Van der Haegen on 07/12/08.
+//  Copyright 2008 __MyCompanyName__. All rights reserved.
+//
+
+#import "CraigSimpleItem.h"
+
+
+@implementation CraigSimpleItem
+
+@synthesize title = _title;
+@synthesize location = _location;
+@synthesize directlink = _directlink;
+@synthesize hasPics = _hasPics;
+@synthesize date = _date;
+
+-(id) init {
+	if (self = [super init]) {
+		self.hasPics = FALSE;
+		_date=@"";
+		_title=nil;
+		_location=nil;
+		_directlink=nil;
+	}
+	return self;
+}
+
+- (void)dealloc {
+	if (_title) {
+		[_title release];
+	}
+	if (_location) {
+		[_location release];
+	}
+	if (_directlink) {
+		[_directlink release];
+	}
+	if (_date) {
+		[_date release];
+	}
+	[super dealloc];
+}
+
+
+
+@end

File ikraigslist/Classes/CraigsListAppDelegate.h

+//
+//  CraigsListAppDelegate.h
+//  CraigsList
+//
+//  Created by Mathieu Van der Haegen on 07/12/08.
+//  Copyright 2008 __MyCompanyName__. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+#import "MasterViewController.h"
+#import "QueryParams.h"
+
+
+
+@interface CraigsListAppDelegate : NSObject <UIApplicationDelegate> {
+	
+	IBOutlet UIWindow *window;
+}
+
+@property (nonatomic, retain) UIWindow *window;
+
+@end

File ikraigslist/Classes/CraigsListAppDelegate.m

+//
+//  CraigListLAppDelegate.m
+//  CraigsList
+//
+//  Created by Mathieu Van der Haegen on 07/12/08.
+//  Copyright 2008 __MyCompanyName__. All rights reserved.
+//
+
+#import "CraigsListAppDelegate.h"
+
+#import <SystemConfiguration/SystemConfiguration.h>
+#import "MasterViewController.h"
+#import "QueryParams.h"
+#import "Manager.h"
+#import "DataManager.h"
+
+
+
+@implementation CraigsListAppDelegate
+
+@synthesize window;
+
+
+
+- init {
+	if (self = [super init]) {
+		// Initialization code
+		
+	}
+	return self;
+}
+
+
+
+- (void)dealloc {
+	[window release];
+
+	[super dealloc];
+}
+
+
+
+
+
+
+
+
+
+
+- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    
+    // Override point for customization after app launch. 
+	[[Manager getMain] setSelectedIndex: [[Manager appParams] currentController]];
+	
+	// Configure and show the window
+	[window addSubview:[[Manager getMain] view]];
+	[window makeKeyAndVisible];
+    
+	
+	return YES;
+}
+
+
+
+
+
+- (void)applicationWillResignActive:(UIApplication *)application {
+    /*
+     Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
+     Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
+     */
+}
+
+
+- (void)applicationDidBecomeActive:(UIApplication *)application {
+    /*
+     Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
+     */
+}
+
+
+- (void)applicationWillTerminate:(UIApplication *)application {
+	NSLog(@"applicationWillTerminate");
+   	[[Manager appParams] setCurrentController:[[Manager getMain] selectedIndex]];
+	[[Manager getHome] pushQueryParams];
+	[[Manager queryParams] saveDB];
+	[[Manager appParams] saveDB];
+	[DataManager closeDB];
+}
+
+
+
+
+
+@end
+

File ikraigslist/Classes/DataManager.h

+//
+//  DataManager.h
+//  CraigsList
+//
+//  Created by Mathieu Van der Haegen on 12/12/08.
+//  Copyright 2008 __MyCompanyName__. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+#import "CraigDetailedItem.h"
+#import "QueryParams.h"
+#import "BookMark.h"
+#import "Region.h"
+#import "Location.h"
+#import "Section.h"
+
+
+@interface DataManager : NSObject {
+
+}
+
++ (NSString*) getValueForKey:(NSString*)thekey;
++ (BOOL) setValue:(NSString*) value forKey:(NSString*)thekey;
++ (void) closeDB;
+
+
++ (Region*) getRegion:(NSInteger)index;
++ (NSInteger) getRegionsCount;
+
++ (NSArray*) getSections;
+
+//+ (NSString*) writeImage:(UIImage*) theImage;
++ (NSString*) writeImageTemp:(UIImage*) theImage;
+
++ (void) deleteImage: (NSString*) theName;
++ (UIImage*) loadImage:(NSString*) filename;
+
++ (BOOL) dropAllParams;
+
+
++ (NSMutableArray*) getSavedQueries;
++ (BOOL) dropSavedQueries;
++ (BOOL) saveQuery:(QueryParams*) params;
++ (BOOL) deleteSavedQuery: (QueryParams*) query;
+
++ (NSMutableArray*) getBookmarks;
++ (BOOL) dropBookmarks;
++ (BOOL) saveBookmark:(BookMark*)book;
++ (BOOL) deleteBookmark:(BookMark*)book;
+
++(NSArray*) getJobsOptionsArray;
++(NSArray*) getJobsUrlOptions;
+
++(NSString*) getDocumentDirectory;
++(NSString*) getTempDirectory;
++(NSString*) getBundleDirectory;
++(NSString*) getLoadingHtml;
+
+@end

File ikraigslist/Classes/DataManager.m

+//
+//  DataManager.m
+//  CraigsList
+//
+//  Created by Mathieu Van der Haegen on 12/12/08.
+//  Copyright 2008 __MyCompanyName__. All rights reserved.
+//
+
+#import "DataManager.h"
+#import "CraigDetailedItem.h"
+#import "BookMark.h"
+#import "QueryParams.h"
+#import <sqlite3.h>
+#import "Manager.h"
+#import "Region.h"
+#import "RegionsParser.h"
+#import "Section.h"
+#import "SectionsParser.h"
+
+static NSMutableArray *sections;
+
+static NSMutableArray *regions;
+static NSArray *jobsOpts;
+static NSArray *jobsUrlOpts;
+
+
+static sqlite3_stmt *insert_statement = nil;
+static sqlite3_stmt *get_statement = nil;
+static sqlite3_stmt *update_statement = nil;
+static sqlite3_stmt *drop_statement = nil;
+
+static sqlite3_stmt *bookmark_insert_statement = nil;
+static sqlite3_stmt *bookmark_delete_statement = nil;
+static sqlite3_stmt *bookmark_drop_statement = nil;
+static sqlite3_stmt *bookmark_get_statement = nil;
+static sqlite3_stmt *bookmark_get_one_statement=nil;
+
+static sqlite3_stmt *query_insert_statement = nil;
+static sqlite3_stmt *query_delete_statement = nil;
+static sqlite3_stmt *query_drop_statement = nil;
+static sqlite3_stmt *query_get_statement = nil;
+static sqlite3_stmt *query_get_one_statement=nil;
+
+
+static sqlite3 *database = nil;
+
+static  NSArray *paths;
+static NSString *documentsDirectory;
+static NSString *mytempDirectory;
+
+static NSString *loadingHtml;
+
+static RegionsParser* rp;
+static SectionsParser* sp;
+
+
+@interface DataManager()
+
++ (void)createEditableCopyOfDatabaseIfNeeded;
++ (NSString*) newUUID;
++ (NSString*) writeImageTemp:(UIImage*) theImage;
++ (void)checkTempDir;
+
+@end
+
+
+
+@implementation DataManager
+
++ (void) initialize {
+	[DataManager createEditableCopyOfDatabaseIfNeeded];
+	
+	rp = [[RegionsParser alloc] init];
+	sp = [[SectionsParser alloc] init];
+	
+	paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
+    documentsDirectory = [[paths objectAtIndex:0] retain];
+	mytempDirectory = [documentsDirectory stringByAppendingPathComponent:@"temp"];
+    NSString *path = [documentsDirectory stringByAppendingPathComponent:@"icraigslist_userdata.sqlite"];
+	
+	loadingHtml = @"<html><head></head><body><br/><div style=\"font-family:serif;text-align:center;font-size:60px;color:purple\"> ikraigslist </div> <div style=\"font-family:arial,sans-serif;text-align:center;font-size:50px;\"><br/><br/><div style=\"font-size:80px;font-weight:bolder;\">Loading</div><br/>please wait ... <br/><br/> <img src=\"loading.gif\" width=\"100\"> </img></div> </body></html>";
+	
+	[self checkTempDir];
+	
+	
+	//opening db
+	if (sqlite3_open([path UTF8String], &database) != SQLITE_OK) {
+		
+        NSAssert1(0, @"Failed to open database with message '%s'.", sqlite3_errmsg(database));
+        // Additional error handling, as appropriate...
+		sqlite3_close(database);
+	}
+	
+	//preparing the statements for params
+	const char *sql = "SELECT value FROM params WHERE key=?";
+	if (sqlite3_prepare_v2(database, sql, -1, &get_statement, NULL) != SQLITE_OK) {
+		NSAssert1(0, @"Error: failed to prepare statement with message '%s'.", sqlite3_errmsg(database));
+	}
+	
+	const char *sql2 = "INSERT INTO params (key,value) VALUES (?,?)";
+	if (sqlite3_prepare_v2(database, sql2, -1, &insert_statement, NULL) != SQLITE_OK) {
+		NSAssert1(0, @"Error: failed to prepare statement with message '%s'.", sqlite3_errmsg(database));
+	}
+	
+	const char *sql3 = "UPDATE params SET value=? WHERE key=?";
+	if (sqlite3_prepare_v2(database, sql3, -1, &update_statement, NULL) != SQLITE_OK) {
+		NSAssert1(0, @"Error: failed to prepare statement with message '%s'.", sqlite3_errmsg(database));
+	}
+	
+	const char *sql31 = "DELETE FROM params WHERE 1";
+	if (sqlite3_prepare_v2(database, sql31, -1, &drop_statement, NULL) != SQLITE_OK) {
+		NSAssert1(0, @"Error: failed to prepare statement with message '%s'.", sqlite3_errmsg(database));
+	}
+	
+	//bookmarks
+	const char *sql4 = "INSERT INTO bookmarks (name,htmlContent,bodyContent,directLink,date,location,emailLink,mapLink,images,title) VALUES (?,?,?,?,?,?,?,?,?,?)";
+	if (sqlite3_prepare_v2(database, sql4, -1, &bookmark_insert_statement, NULL) != SQLITE_OK) {
+		NSAssert1(0, @"Error: failed to prepare statement with message '%s'.", sqlite3_errmsg(database));