mirror of
https://github.com/gnustep/libs-gdl2.git
synced 2025-02-21 02:20:55 +00:00
* EOAdaptors/SQLiteAdaptor/GNUmakefile.in: Add login panel.
* EOAdaptors/SQLiteAdaptor/LoginPanel: New directory. * EOAdaptors/SQLiteAdaptor/LoginPanel/GNUmakefile: New file. * EOAdaptors/SQLiteAdaptor/LoginPanel/Makefile.postamble: Ditto * EOAdaptors/SQLiteAdaptor/LoginPanel/SQLite3LoginPanel.m: Ditto. * EOAdaptors/SQLiteAdaptor/LoginPanel/SQLite3LoginPanel.h: Ditto. * variable-processing.make: Add comments. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@24305 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
c4bf6fba06
commit
17f3fcbd6b
7 changed files with 478 additions and 0 deletions
11
ChangeLog
11
ChangeLog
|
@ -1,3 +1,14 @@
|
|||
2006-01-02 Matt Rice <ratmice@gmail.com>
|
||||
|
||||
* EOAdaptors/SQLiteAdaptor/GNUmakefile.in: Add login panel.
|
||||
* EOAdaptors/SQLiteAdaptor/LoginPanel: New directory.
|
||||
* EOAdaptors/SQLiteAdaptor/LoginPanel/GNUmakefile: New file.
|
||||
* EOAdaptors/SQLiteAdaptor/LoginPanel/Makefile.postamble: Ditto
|
||||
* EOAdaptors/SQLiteAdaptor/LoginPanel/SQLite3LoginPanel.m: Ditto.
|
||||
* EOAdaptors/SQLiteAdaptor/LoginPanel/SQLite3LoginPanel.h: Ditto.
|
||||
* variable-processing.make: Add comments.
|
||||
|
||||
|
||||
2007-01-01 David Ayers <ayers@fsfe.org>
|
||||
|
||||
* EOAccess/EOAccessFault.h/m: Minor cleanups for autogsdoc.
|
||||
|
|
|
@ -23,6 +23,8 @@
|
|||
#
|
||||
include $(GNUSTEP_MAKEFILES)/common.make
|
||||
|
||||
SUBPROJECTS=LoginPanel
|
||||
|
||||
ADDITIONAL_INCLUDE_DIRS+=@SQLITE3_INCLUDES@
|
||||
ADDITIONAL_LIB_DIRS+=@SQLITE3_LIB_DIRS@
|
||||
LIBRARIES_DEPEND_UPON+=@SQLITE3_LIBS@
|
||||
|
@ -39,6 +41,8 @@ SQLite3Channel.m
|
|||
|
||||
|
||||
include ../../common.make
|
||||
|
||||
include $(GNUSTEP_MAKEFILES)/aggregate.make
|
||||
include $(GNUSTEP_MAKEFILES)/framework.make
|
||||
-include Makefile.postamble
|
||||
|
||||
|
|
52
EOAdaptors/SQLiteAdaptor/LoginPanel/GNUmakefile
Normal file
52
EOAdaptors/SQLiteAdaptor/LoginPanel/GNUmakefile
Normal file
|
@ -0,0 +1,52 @@
|
|||
# -*-Makefile-*-
|
||||
# GNUmakefile
|
||||
#
|
||||
# Copyright (C) 2004, 2005 Free Software Foundation, Inc.
|
||||
#
|
||||
# Author: Matt Rice <ratmice@yahoo.com>
|
||||
# Date: January 2006
|
||||
#
|
||||
# This file is part of the GNUstep Database Library
|
||||
#
|
||||
# The GNUstep Database Library is free software; you can redistribute it
|
||||
# and/or modify it under the terms of the GNU Lesser General Public License
|
||||
# as published by the Free Software Foundation; either version 2,
|
||||
# or (at your option) any later version.
|
||||
#
|
||||
# The GNUstep Database Library is distributed in the hope that it will be
|
||||
# useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with the GNUstep Database Library; see the file COPYING.
|
||||
# If not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
include $(GNUSTEP_MAKEFILES)/common.make
|
||||
|
||||
BUNDLE_NAME=LoginPanel
|
||||
ifneq ($(GUI_MAKE_LOADED),yes)
|
||||
ifneq ($(GUI_LIB),apple)
|
||||
BUNDLE_NAME=
|
||||
endif
|
||||
endif
|
||||
|
||||
LoginPanel_OBJC_FILES=SQLite3LoginPanel.m
|
||||
LoginPanel_PRINCIPAL_CLASS=SQLite3LoginPanel
|
||||
|
||||
LoginPanel_INCLUDE_DIRS=-I.. -I../../../
|
||||
ADDITIONAL_NATIVE_LIBS+=EOAccess EOControl
|
||||
ADDITIONAL_NATIVE_LIB_DIRS+=../../../EOControl ../../../EOAccess
|
||||
|
||||
ifneq ($(FOUNDATION_LIB),gnu)
|
||||
LoginPanel_OBJC_LIBS+=-lgnustep-baseadd
|
||||
endif
|
||||
|
||||
LoginPanel_COPY_INTO_DIR=../SQLite3EOAdaptor.framework/Resources
|
||||
-include ../config.mak
|
||||
-include Makefile.preamable
|
||||
include ../../../common.make
|
||||
-include GNUmakefile.local
|
||||
include $(GNUSTEP_MAKEFILES)/bundle.make
|
||||
-include Makefile.postamble
|
83
EOAdaptors/SQLiteAdaptor/LoginPanel/Makefile.postamble
Normal file
83
EOAdaptors/SQLiteAdaptor/LoginPanel/Makefile.postamble
Normal file
|
@ -0,0 +1,83 @@
|
|||
# -*-makefile-*-
|
||||
# Makefile.postamble
|
||||
#
|
||||
# Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
# Author: Matt Rice <ratmice@gmail.com>
|
||||
#
|
||||
# This file is part of the GNUstep Database Library.
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This library is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# Library General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with this library; see the file COPYING.LIB.
|
||||
# If not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
#
|
||||
|
||||
#
|
||||
# Makefile.postamble
|
||||
#
|
||||
# Project specific makefile rules
|
||||
#
|
||||
# Uncomment the targets you want.
|
||||
# The double colons (::) are important, do not make them single colons
|
||||
# otherwise the normal makefile rules will not be performed.
|
||||
#
|
||||
|
||||
# Things to do before compiling
|
||||
ifneq ($(GUI_MAKE_LOADED),yes)
|
||||
ifneq ($(GUI_LIB),apple)
|
||||
before-all::
|
||||
@echo Skipping login panel compilation. GNUstep gui not installed.
|
||||
endif
|
||||
endif
|
||||
#before-all::
|
||||
|
||||
# Things to do after compiling
|
||||
# after-all::
|
||||
|
||||
# Things to do before installing
|
||||
# before-install::
|
||||
|
||||
#
|
||||
# The following rule is important mainly for packaging, because in that case
|
||||
# you install into a fake system tree, and the directory is not there.
|
||||
#
|
||||
|
||||
# Things to do after installing
|
||||
# after-install::
|
||||
|
||||
# Things to do before uninstalling
|
||||
# before-uninstall::
|
||||
|
||||
# Things to do after uninstalling
|
||||
# after-uninstall::
|
||||
|
||||
# Things to do before cleaning
|
||||
# before-clean::
|
||||
|
||||
# Things to do after cleaning
|
||||
#after-clean::
|
||||
|
||||
# Things to do before distcleaning
|
||||
# before-distclean::
|
||||
|
||||
# Things to do after distcleaning
|
||||
after-distclean::
|
||||
rm -rf config.mak
|
||||
|
||||
# Things to do before checking
|
||||
# before-check::
|
||||
|
||||
# Things to do after checking
|
||||
# after-check::
|
||||
|
42
EOAdaptors/SQLiteAdaptor/LoginPanel/SQLite3LoginPanel.h
Normal file
42
EOAdaptors/SQLiteAdaptor/LoginPanel/SQLite3LoginPanel.h
Normal file
|
@ -0,0 +1,42 @@
|
|||
/** -*-ObjC-*-
|
||||
SQLite3LoginPanel.h
|
||||
|
||||
Copyright (C) 2004,2005 Free Software Foundation, Inc.
|
||||
|
||||
Author: Matt Rice <ratmice@gmail.com>
|
||||
Date: January 2006
|
||||
|
||||
This file is part of the GNUstep Database Library
|
||||
|
||||
The GNUstep Database Library is free software; you can redistribute it
|
||||
and/or modify it under the terms of the GNU Lesser General Public License
|
||||
as published by the Free Software Foundation; either version 2,
|
||||
or (at your option) any later version.
|
||||
|
||||
The GNUstep Database Library is distributed in the hope that it will be
|
||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with the GNUstep Database Library; see the file COPYING. If not,
|
||||
write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
|
||||
#include <EOAccess/EOAccess.h>
|
||||
|
||||
@class NSPanel;
|
||||
@class NSTextField;
|
||||
@class NSButton;
|
||||
|
||||
@interface SQLite3LoginPanel : EOLoginPanel
|
||||
{
|
||||
NSPanel *_win;
|
||||
NSTextField *_path;
|
||||
NSButton *_browse;
|
||||
NSButton *_ok;
|
||||
NSButton *_cancel;
|
||||
}
|
||||
@end
|
275
EOAdaptors/SQLiteAdaptor/LoginPanel/SQLite3LoginPanel.m
Normal file
275
EOAdaptors/SQLiteAdaptor/LoginPanel/SQLite3LoginPanel.m
Normal file
|
@ -0,0 +1,275 @@
|
|||
/** -*-ObjC-*-
|
||||
SQLite3LoginPanel.m
|
||||
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
Author: Matt Rice <ratmice@gmail.com>
|
||||
Date: January 2006
|
||||
|
||||
This file is part of the GNUstep Database Library
|
||||
|
||||
The GNUstep Database Library is free software; you can redistribute it
|
||||
and/or modify it under the terms of the GNU Lesser General Public License
|
||||
as published by the Free Software Foundation; either version 2,
|
||||
or (at your option) any later version.
|
||||
|
||||
The GNUstep Database Library is distributed in the hope that it will be
|
||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with the GNUstep Database Library; see the file COPYING. If not,
|
||||
write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
|
||||
#include "SQLite3LoginPanel.h"
|
||||
|
||||
#import <AppKit/AppKit.h>
|
||||
|
||||
static BOOL insideModalLoop = YES;
|
||||
|
||||
@interface SQLite3LoginPanel(Private)
|
||||
- (NSDictionary *)_runPanelForAdaptor:(EOAdaptor *)adaptor
|
||||
validate:(BOOL)flag
|
||||
allowsCreation:(BOOL)allowsCreation
|
||||
requiresAdministration:(BOOL)adminFlag;
|
||||
-(void)_assertConnectionDictionaryIsValidForAdaptor:(EOAdaptor *)adaptor
|
||||
requiresAdministration:(BOOL)adminFlag;
|
||||
@end
|
||||
|
||||
|
||||
@implementation SQLite3LoginPanel
|
||||
|
||||
- (id) init
|
||||
{
|
||||
if ((self = [super init]))
|
||||
{
|
||||
NSRect fr1, fr2;
|
||||
float w;
|
||||
_win = [[NSPanel alloc] initWithContentRect:NSMakeRect(0, 0, 256, 128)
|
||||
styleMask: NSTitledWindowMask
|
||||
backing:NSBackingStoreBuffered
|
||||
defer:YES];
|
||||
[_win center];
|
||||
_ok = [[NSButton alloc] init];
|
||||
_cancel = [[NSButton alloc] init];
|
||||
[_ok setTitle:@"Ok"];
|
||||
[_cancel setTitle:@"Cancel"];
|
||||
|
||||
[_ok sizeToFit];
|
||||
[_cancel sizeToFit];
|
||||
|
||||
fr1 = [_ok frame];
|
||||
fr2 = [_cancel frame];
|
||||
[_ok setFrame:NSMakeRect(252 - fr2.size.width, 4, fr2.size.width, fr2.size.height)];
|
||||
|
||||
fr1 = [_ok frame];
|
||||
[_cancel setFrameOrigin:NSMakePoint(fr1.origin.x - fr2.size.width - 4, 4)];
|
||||
_browse = [[NSButton alloc] initWithFrame:NSMakeRect(NSMaxX(fr2) + 4, NSMaxY(fr1) + 4, 0, 0)];
|
||||
[_browse setTitle:@"Browse"];
|
||||
[_browse sizeToFit];
|
||||
fr2 = [_browse frame];
|
||||
[_browse setFrame:NSMakeRect(256 - fr2.size.width - 4, NSMaxY(fr1) + 4, fr2.size.width, fr2.size.height)];
|
||||
fr2 = [_browse frame];
|
||||
|
||||
w = 256 - fr2.size.width - 12;
|
||||
_path = [[NSTextField alloc] initWithFrame: NSMakeRect(NSMinX(fr2) - w - 4, NSMaxY(fr1) + 4, w, fr2.size.height)];
|
||||
|
||||
[_ok setTarget:self];
|
||||
[_cancel setTarget:self];
|
||||
[_browse setTarget:self];
|
||||
|
||||
[_ok setAction:@selector(ok:)];
|
||||
[_cancel setAction:@selector(cancel:)];
|
||||
[_browse setAction:@selector(browse:)];
|
||||
|
||||
[[_win contentView] addSubview:_ok];
|
||||
[[_win contentView] addSubview:_cancel];
|
||||
[[_win contentView] addSubview:_browse];
|
||||
[[_win contentView] addSubview:_path];
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (NSDictionary *) _runPanelForAdaptor:(EOAdaptor *)adaptor
|
||||
validate:(BOOL)flag
|
||||
allowsCreation:(BOOL) allowsCreation
|
||||
requiresAdministration:(BOOL)adminFlag
|
||||
{
|
||||
int modalCode;
|
||||
volatile BOOL keepLooping = YES;
|
||||
NSDictionary *connDict;
|
||||
NSString *reason;
|
||||
|
||||
while (keepLooping)
|
||||
{
|
||||
if (!flag) keepLooping = NO;
|
||||
|
||||
insideModalLoop = YES;
|
||||
|
||||
modalCode = [NSApp runModalForWindow:_win];
|
||||
|
||||
if (modalCode == NSRunStoppedResponse)
|
||||
{
|
||||
insideModalLoop = NO;
|
||||
connDict = RETAIN([NSDictionary
|
||||
dictionaryWithObject:[_path stringValue]
|
||||
forKey:@"databasePath"]);
|
||||
[adaptor setConnectionDictionary:connDict];
|
||||
|
||||
if (flag)
|
||||
{
|
||||
NS_DURING
|
||||
[self _assertConnectionDictionaryIsValidForAdaptor:adaptor
|
||||
requiresAdministration:adminFlag];
|
||||
NS_HANDLER
|
||||
reason = [localException reason];
|
||||
NSRunAlertPanel(@"Invalid connection dictionary",
|
||||
reason, nil, nil, nil);
|
||||
NS_ENDHANDLER
|
||||
|
||||
}
|
||||
}
|
||||
if (modalCode == NSRunAbortedResponse)
|
||||
{
|
||||
insideModalLoop = NO;
|
||||
connDict = nil;
|
||||
keepLooping = NO;
|
||||
}
|
||||
}
|
||||
[_win orderOut:self];
|
||||
NSLog(@"%@", connDict);
|
||||
return AUTORELEASE(connDict);
|
||||
}
|
||||
|
||||
- (NSDictionary *)administrativeConnectionDictionaryForAdaptor:(EOAdaptor *)adaptor;
|
||||
{
|
||||
return [self _runPanelForAdaptor:adaptor
|
||||
validate:YES
|
||||
allowsCreation:NO
|
||||
requiresAdministration:YES];
|
||||
}
|
||||
|
||||
- (NSDictionary *)runPanelForAdaptor:(EOAdaptor *)adaptor
|
||||
validate:(BOOL)flag
|
||||
allowsCreation:(BOOL)allowsCreation
|
||||
{
|
||||
return [self _runPanelForAdaptor:adaptor
|
||||
validate:flag
|
||||
allowsCreation:allowsCreation
|
||||
requiresAdministration:NO];
|
||||
}
|
||||
|
||||
|
||||
|
||||
- (void) _assertConnectionDictionaryIsValidForAdaptor:(EOAdaptor *)adaptor
|
||||
requiresAdministration:(BOOL)adminFlag
|
||||
{
|
||||
volatile NSException *exception = nil;
|
||||
EOAdaptorContext *adaptorContext;
|
||||
EOAdaptorChannel *adaptorChannel;
|
||||
|
||||
if (![adaptor hasOpenChannels])
|
||||
{
|
||||
adaptorContext = [adaptor createAdaptorContext];
|
||||
adaptorChannel = [adaptorContext createAdaptorChannel];
|
||||
|
||||
NS_DURING
|
||||
[adaptorChannel openChannel];
|
||||
NS_HANDLER
|
||||
exception = localException;
|
||||
NS_ENDHANDLER
|
||||
|
||||
if ([adaptorChannel isOpen])
|
||||
{
|
||||
if (adminFlag)
|
||||
{
|
||||
NSString *path = [[adaptor connectionDictionary]
|
||||
objectForKey:@"databasePath"];
|
||||
NSFileManager *fm = [NSFileManager defaultManager];
|
||||
BOOL isDir;
|
||||
BOOL exists;
|
||||
BOOL isW;
|
||||
|
||||
exists = [fm fileExistsAtPath:path isDirectory:&isDir];
|
||||
|
||||
if ([path length] && !isDir)
|
||||
{
|
||||
isW = [fm isWritableFileAtPath:path];
|
||||
if (exists && !isW)
|
||||
{
|
||||
exception =
|
||||
[NSException
|
||||
exceptionWithName:@"Invalid ConnectionDictionary"
|
||||
reason:@"Database path is not writable"
|
||||
userInfo:[adaptor connectionDictionary]];
|
||||
}
|
||||
else
|
||||
{
|
||||
path = [path lastPathComponent];
|
||||
exists = [fm fileExistsAtPath:path isDirectory:&isDir];
|
||||
isW = [fm isWritableFileAtPath:path];
|
||||
if (!exists || !isW)
|
||||
{
|
||||
exception =
|
||||
[NSException
|
||||
exceptionWithName:@"Invalid ConnectionDictionary"
|
||||
reason:@"Database path is not writable"
|
||||
userInfo:[adaptor connectionDictionary]];
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
exception =
|
||||
[NSException
|
||||
exceptionWithName:@"Invalid ConnectionDictionary"
|
||||
reason:@"Database path is invalid."
|
||||
userInfo:[adaptor connectionDictionary]];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (exception)
|
||||
[exception raise];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)ok:(id)sender
|
||||
{
|
||||
if (insideModalLoop)
|
||||
{
|
||||
[NSApp stopModalWithCode:NSRunStoppedResponse];
|
||||
}
|
||||
}
|
||||
|
||||
- (void) cancel:(id)sender
|
||||
{
|
||||
if (insideModalLoop)
|
||||
{
|
||||
[NSApp stopModalWithCode:NSRunAbortedResponse];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)browse:(id)sender
|
||||
{
|
||||
int code;
|
||||
id panel = [NSSavePanel savePanel];
|
||||
NSString *file;
|
||||
|
||||
[panel setAllowedFileTypes:nil];
|
||||
code = [panel runModalForDirectory:NSHomeDirectory() file:nil];
|
||||
file = [panel filename];
|
||||
|
||||
|
||||
if (code == NSOKButton && file)
|
||||
{
|
||||
[_path setStringValue:file];
|
||||
}
|
||||
}
|
||||
@end
|
||||
|
|
@ -1,3 +1,14 @@
|
|||
#
|
||||
# Heres a way to compile/link against a framework/library before the library is
|
||||
# installed.
|
||||
#
|
||||
# It depends upon the source layout of GDL2 where the directories are the same
|
||||
# name as the framework name, for the -F flag to work.
|
||||
#
|
||||
# this is only comparable to the -L flags of a normal library, -I flags
|
||||
# for this are redundant so just use typical ADDITONAL_INCLUDE_DIRS.
|
||||
#
|
||||
|
||||
ifeq ($(FOUNDATION_LIB), apple)
|
||||
ADDITIONAL_LIB_DIRS += $(foreach libdir,$(ADDITIONAL_NATIVE_LIB_DIRS),-F$(libdir))
|
||||
else
|
||||
|
|
Loading…
Reference in a new issue