[Mysql-cocoa-commits] CVS: SMySQL/MCPFoundationKit MCPConnection.h,1.1,1.2 MCPConnection.m,1.1,1.2 M
Brought to you by:
sergecohen
|
From: Serge C. <ser...@us...> - 2003-10-11 20:32:29
|
Update of /cvsroot/mysql-cocoa/SMySQL/MCPFoundationKit
In directory sc8-pr-cvs1:/tmp/cvs-serv2316/MCPFoundationKit
Modified Files:
MCPConnection.h MCPConnection.m MCPResult.m
Log Message:
Correction of the MCPConnection -init method (does not try to get some encoding information, use a default of ISO1).
Modified the interface to setOption method, together with a first test implementation.
2003-10-10; Serge Cohen.
Index: MCPConnection.h
===================================================================
RCS file: /cvsroot/mysql-cocoa/SMySQL/MCPFoundationKit/MCPConnection.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** MCPConnection.h 11 Oct 2003 18:48:07 -0000 1.1
--- MCPConnection.h 11 Oct 2003 20:32:25 -0000 1.2
***************
*** 45,48 ****
--- 45,49 ----
BOOL mConnected; /*"Reflect the fact that the connection is already in place or not"*/
NSStringEncoding mEncoding; /*"The encoding used by MySQL server, to ISO-1 default"*/
+ unsigned int mConnectionFlags; /*"The flags to be used for the connection to the database."*/
}
/*"
***************
*** 66,70 ****
- (id) initToSocket:(NSString *) socket withLogin:(NSString *) login password:(NSString *) pass;
! - (BOOL) setConnectionOption:(int) option withArgument:(id) arg;
// Port to 0 to use the default port
- (BOOL) connectWithLogin:(NSString *) login password:(NSString *) pass host:(NSString *) host port:(int) port socket:(NSString *) socket;
--- 67,71 ----
- (id) initToSocket:(NSString *) socket withLogin:(NSString *) login password:(NSString *) pass;
! - (BOOL) setConnectionOption:(int) option toValue:(BOOL) value;
// Port to 0 to use the default port
- (BOOL) connectWithLogin:(NSString *) login password:(NSString *) pass host:(NSString *) host port:(int) port socket:(NSString *) socket;
Index: MCPConnection.m
===================================================================
RCS file: /cvsroot/mysql-cocoa/SMySQL/MCPFoundationKit/MCPConnection.m,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** MCPConnection.m 11 Oct 2003 18:48:07 -0000 1.1
--- MCPConnection.m 11 Oct 2003 20:32:25 -0000 1.2
***************
*** 122,126 ****
{
if (self = [MCPConnection class]) {
! [self setVersion:020000]; // Ma.Mi.Re -> MaMiRe
}
--- 122,126 ----
{
if (self = [MCPConnection class]) {
! [self setVersion:020202]; // Ma.Mi.Re -> MaMiRe
}
***************
*** 137,140 ****
--- 137,146 ----
/*"
Initialise a MySQLConnection without making a connection, most likely useless, except with !{setConnectionOption:withArgument:}.
+
+ Because this method is not making a connection to any MySQL server, it can not know already what the DB server encoding will be,
+ hence the encoding is set to some default (at present this is NSISOLatin1StringEncoding). Obviously this is reset to a proper
+ value as soon as a DB connection is performed.
+
+ #{I AM CURRENTLY NOT TESTING THIS METHOD, so it is likely to be buggy}... I'd be SUPER happy to ear/read your feed-back on this.
"*/
{
***************
*** 146,151 ****
return nil;
}
! // mEncoding = NSISOLatin1StringEncoding;
! mEncoding = [MCPConnection encodingForMySQLEncoding:mysql_character_set_name(mConnection)];
return self;
}
--- 152,158 ----
return nil;
}
! mEncoding = NSISOLatin1StringEncoding;
! mConnectionFlags = kMCPConnectionDefaultOption;
! // mEncoding = [MCPConnection encodingForMySQLEncoding:mysql_character_set_name(mConnection)];
return self;
}
***************
*** 181,184 ****
--- 188,193 ----
}
+ mConnectionFlags = kMCPConnectionDefaultOption;
+
[self connectWithLogin:login password:pass host:host port:port socket:nil];
return self;
***************
*** 214,217 ****
--- 223,228 ----
}
+ mConnectionFlags = kMCPConnectionDefaultOption;
+
[self connectWithLogin:login password:pass host:NULL port:0 socket:socket];
return self;
***************
*** 219,225 ****
! - (BOOL) setConnectionOption:(int) option withArgument:(id) arg
/*"
! #{NOT YET IMPLEMENTED}
This method is to be used for getting special option for a connection, in which case the MCPConnection has to be inited with the init method, then option are selected, finally connection is done using one of the connect methods:
--- 230,236 ----
! - (BOOL) setConnectionOption:(int) option toValue:(BOOL) value
/*"
! #{IMPLEMENTED BUT NOT TESTED!!}
This method is to be used for getting special option for a connection, in which case the MCPConnection has to be inited with the init method, then option are selected, finally connection is done using one of the connect methods:
***************
*** 227,231 ****
!{
MCPConnection *theConnect = [[MCPConnection alloc] init];
! [theConnect setConnectionOption: option withArgument: arg];
[theConnect connectToHost:albert.com withLogin:@"toto" password:@"albert" port:0];
....
--- 238,242 ----
!{
MCPConnection *theConnect = [[MCPConnection alloc] init];
! [theConnect setConnectionOption: option toValue: value];
[theConnect connectToHost:albert.com withLogin:@"toto" password:@"albert" port:0];
....
***************
*** 239,242 ****
--- 250,260 ----
return FALSE;
}
+ #warning Have to check the syntax of the following assignements:
+ if (value) { //Set this option to true
+ mConnectionFlags |= option;
+ }
+ else { //Set this option to false
+ mConnectionFlags &= (! option);
+ }
return YES;
}
***************
*** 279,283 ****
}
! theRet = mysql_real_connect(mConnection, theHost, theLogin, thePass, NULL, port, theSocket, kMCPConnectionDefaultOption);
if (theRet != mConnection) {
return mConnected = NO;
--- 297,301 ----
}
! theRet = mysql_real_connect(mConnection, theHost, theLogin, thePass, NULL, port, theSocket, mConnectionFlags);
if (theRet != mConnection) {
return mConnected = NO;
Index: MCPResult.m
===================================================================
RCS file: /cvsroot/mysql-cocoa/SMySQL/MCPFoundationKit/MCPResult.m,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** MCPResult.m 11 Oct 2003 18:48:07 -0000 1.1
--- MCPResult.m 11 Oct 2003 20:32:25 -0000 1.2
***************
*** 71,75 ****
{
if (self = [MCPResult class]) {
! [self setVersion:020000]; // Ma.Mi.Re -> MaMiRe
MCPYear0000 = [[NSCalendarDate dateWithTimeIntervalSinceReferenceDate:-63146822400.0] retain];
[MCPYear0000 setCalendarFormat:@"%Y"];
--- 71,75 ----
{
if (self = [MCPResult class]) {
! [self setVersion:020202]; // Ma.Mi.Re -> MaMiRe
MCPYear0000 = [[NSCalendarDate dateWithTimeIntervalSinceReferenceDate:-63146822400.0] retain];
[MCPYear0000 setCalendarFormat:@"%Y"];
|