MCPDocument


Inherits From:
NSDocument
Declared In:
MCPDocument.h


Class Description

No class description.


Instance Variables

BOOL MCPConInfoNeeded, MCPPassNeeded;
NSString *MCPHost, *MCPLogin, *MCPDatabase;
unsigned int MCPPort;
MCPConnection *MCPConnect;
NSWindowController *MCPMainWinCont;
Class MCPConnectedWinCont;
NSString *MCPModelName;
BOOL MCPWillCreateNewDB;

MCPPassNeededNo description.
MCPDatabaseNo description.
MCPPortNo description.
MCPConnectNo description.
MCPMainWinContNo description.
MCPConnectedWinContWindow controller used once the connection is established (As a class).
MCPModelNameNo description.
MCPWillCreateNewDBNo description.


Method Types

Class Maintenance
+ initialize
Initialisation and deallocation
- init
- dealloc
Connection to the databse related
- MCPqueryString:
- MCPinsertRow:
- MCPgetConnection
Accessors to the parameters of the connection
- setMCPHost:
- setMCPLogin:
- setMCPDatabase:
- setMCPPort:
- setMCPConInfoNeeded:
- MCPHost
- MCPLogin
- MCPDatabase
- MCPPort
- MCPConInfoNeeded
- MCPPassNeeded
- MCPisConnected
- MCPConnect
Accessor to the window generated once the connection is established
- setMCPConnectedWinCont:
- MCPConnectedWinCont
Accessors to the main window (connection or connected window), through their window controller.
- MCPMainWinCont
Accessors to the DB creation instances.
- setMCPModelName:
- setMCPWillCreateNewDB:
- MCPModelName
- MCPWillCreateNewDB
Practical creation of the database, from a model file.
- createModelDB
Overrides of NSDocument methods.
- dataRepresentationOfType:
- loadDataRepresentation:ofType:
- makeWindowControllers
- windowControllerDidLoadNib:
Method to take care of the password sheet.
- MCPPasswordSheetDidEnd:returnCode:contextInfo:


Class Methods

initialize

+ (void)initialize

No method description.


Instance Methods

MCPConInfoNeeded

- (BOOL)MCPConInfoNeeded

Return the status of the gathering of information for the connection.


MCPConnect

- (MCPConnection *)MCPConnect

Return a pointer to the used MCPConnection. SHOULD NOT be used (one should rather use the connection methods : MCPqueryString: or MCPinsertRow:)


MCPConnectedWinCont

- (Class)MCPConnectedWinCont

Return the Class object of the class used for the main document window (once the connection to the DB server is established).


MCPDatabase

- (NSString *)MCPDatabase

Returns the actual database name of the used db server.


MCPHost

- (NSString *)MCPHost

Returns the actual hostname of the used db server.


MCPLogin

- (NSString *)MCPLogin

Returns the actual login to the used db server.


MCPMainWinCont

- (NSWindowController *)MCPMainWinCont

Return the current main window controller for the document (closing this window causes a close of the document).


MCPModelName

- (NSString *)MCPModelName

No method description.


MCPPassNeeded

- (BOOL)MCPPassNeeded

Return the status of the gathering of the password for the connection.


MCPPasswordSheetDidEnd:returnCode:contextInfo:

- (void)MCPPasswordSheetDidEnd:(NSWindow *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo

Method called once the user enterred the password and click Ok (or press return) Try to make a connection (depending of the button clicked), if password is refused, go back to ask connection information.


MCPPort

- (unsigned int)MCPPort

Returns the port used to connect to the database server (0 means default: from mysql.h -> MYSQL_PORT=3306).


MCPWillCreateNewDB

- (BOOL)MCPWillCreateNewDB

No method description.


MCPgetConnection

- (MCPConnection *)MCPgetConnection

Get directly the MCPConnection of the MCPDocument... This method should be used with care, because one can (inadvertly) modify the DB connection of the document itself, producing further inexpected state later.


MCPinsertRow:

- (unsigned int)MCPinsertRow:(NSString *)insert

Method to use to insert a new row in a table, will return the primary key (auto_increment column) of the new record.


MCPisConnected

- (BOOL)MCPisConnected

Check if the connection is working.


MCPqueryString:

- (MCPResult *)MCPqueryString:(NSString *)query

Send a query to the MCPConnection instance variable. For insert queries, one should prefer the insert: method, which return the primary key (auto_increment) of the new row.


createModelDB

- (BOOL)createModelDB

No method description.


dataRepresentationOfType:

- (NSData *)dataRepresentationOfType:(NSString *)aType

Return data correspoding to archived dictionary containing the parameters for the connection (except for the password, not saved).


dealloc

- (void)dealloc

Deallocation of the object... autorelease all the members.


init

- (id)init

Initialisation of the MCPDocument object, by default every thing is setted to null (or empty), accordingly to that the mConInfoNeeded is setted to YES (true): the connection information (parameters) ARE needed.


loadDataRepresentation:ofType:

- (BOOL)loadDataRepresentation:(NSData *)data ofType:(NSString *)aType

Load a file containing the connection parameters (except for the password) in the instance of the MCPDocument.


makeWindowControllers

- (NSArray *)makeWindowControllers

Make the proper window: either the Connection Info window or the main browser window.


setMCPConInfoNeeded:

- (void)setMCPConInfoNeeded:(BOOL)theConInfoNeeded

VERY IMPORTANT method! Change the value of mConInfoNeeded AND toggle the states of the object, removing appropriate window and displaying other(s) ...


setMCPConnectedWinCont:

- (void)setMCPConnectedWinCont:(Class)theConnectedWinCont

Use to set the type of NSWindowController to be used for the main window of the document once the connection as been established.


setMCPDatabase:

- (void)setMCPDatabase:(NSString *)theDatabase

Sets the name of the database to use on the db server (doesn't accept changes once mConInfoNeeded is NO).


setMCPHost:

- (void)setMCPHost:(NSString *)theHost

Sets the name of the host to which to connect (the one which the db server runs) (doesn't accept changes once MCPConInfoNeeded is NO).


setMCPLogin:

- (void)setMCPLogin:(NSString *)theLogin

Sets the name of the database to use on the db server (doesn't accept changes once MCPConInfoNeeded is NO).


setMCPModelName:

- (void)setMCPModelName:(NSString *)theModelName

No method description.


setMCPPort:

- (void)setMCPPort:(unsigned int)thePort

Set the port to use to connect to the database server (doesn't accept changes once mConInfoNeeded is NO).


setMCPWillCreateNewDB:

- (void)setMCPWillCreateNewDB:(BOOL)theWillCreateNewDB

No method description.


windowControllerDidLoadNib:

- (void)windowControllerDidLoadNib:(NSWindowController *)aController

What to do when a specific window is loaded: - Nothing for the Connection Info Window (MCPConnectionWindow.nib). - Whatever one wants for another window type.

Indeed it looks like this method is never called, unless one has a single window controller document... not the case here...


Version 1.1 Copyright ©2004 by Serge Cohen. All Rights Reserved. Mon Aug 09 11:00:28 2004