mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-23 09:04:13 +00:00
* Headers/Foundation/NSMetadata.h: Add _ to delegate.
* Source/GNUmakefile: Remove reference to NSMetadata.m * Source/NSMetadata.m: Remove from here and add OS specific implementations. * Source/unix/GNUmakefile: Add new file... * Source/unix/NSMetadata.m: UNIX implementation... * Source/win32/GNUmakefile: Add new file.. * Source/win32/NSMetadata.m: Windows implementation. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@35932 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
18b53c8777
commit
feb7c308aa
7 changed files with 363 additions and 26 deletions
11
ChangeLog
11
ChangeLog
|
@ -1,3 +1,14 @@
|
|||
2013-01-05 00:49-EST Gregory John Casamento <greg.casamento@gmail.com>
|
||||
|
||||
* Headers/Foundation/NSMetadata.h: Add _ to delegate.
|
||||
* Source/GNUmakefile: Remove reference to NSMetadata.m
|
||||
* Source/NSMetadata.m: Remove from here and add OS specific
|
||||
implementations.
|
||||
* Source/unix/GNUmakefile: Add new file...
|
||||
* Source/unix/NSMetadata.m: UNIX implementation...
|
||||
* Source/win32/GNUmakefile: Add new file..
|
||||
* Source/win32/NSMetadata.m: Windows implementation.
|
||||
|
||||
2012-12-18 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/NSNetServices.m: patch by Marcus Muller to correctly check
|
||||
|
|
|
@ -81,7 +81,7 @@ GS_EXPORT NSString * const NSMetadataQueryGatheringProgressNotification;
|
|||
NSTimeInterval _notificationBatchingInterval;
|
||||
NSMutableDictionary *_results;
|
||||
|
||||
id<NSMetadataQueryDelegate> delegate;
|
||||
id<NSMetadataQueryDelegate> _delegate;
|
||||
}
|
||||
|
||||
/* Instance methods */
|
||||
|
|
|
@ -227,7 +227,6 @@ NSLocale.m \
|
|||
NSLock.m \
|
||||
NSLog.m \
|
||||
NSMapTable.m \
|
||||
NSMetadata.m \
|
||||
NSMethodSignature.m \
|
||||
NSNotification.m \
|
||||
NSNotificationCenter.m \
|
||||
|
|
|
@ -32,7 +32,8 @@ SUBPROJECT_NAME = unix
|
|||
|
||||
unix_OBJC_FILES = \
|
||||
GSRunLoopCtxt.m \
|
||||
NSStream.m
|
||||
NSStream.m \
|
||||
NSMetadata.m
|
||||
|
||||
-include Makefile.preamble
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#import "Foundation/NSArray.h"
|
||||
#import "Foundation/NSDictionary.h"
|
||||
#import "Foundation/NSString.h"
|
||||
#import "Foundation/NSTimer.h"
|
||||
#import "GNUstepBase/NSObject+GNUstepBase.h"
|
||||
|
||||
// Metadata item constants...
|
||||
|
@ -81,6 +82,18 @@ NSString * const NSMetadataQueryGatheringProgressNotification = @"NSMetadataQuer
|
|||
|
||||
@implementation NSMetadataQuery
|
||||
|
||||
- (id) init
|
||||
{
|
||||
if((self = [super init]) != nil)
|
||||
{
|
||||
_isStopped = YES;
|
||||
_isGathering = NO;
|
||||
_isStarted = NO;
|
||||
_notificationBatchingInterval = (NSTimeInterval)0.0;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
/* Instance methods */
|
||||
- (id)valueOfAttribute:(id)attr forResultAtIndex:(NSUInteger)index
|
||||
{
|
||||
|
@ -138,20 +151,17 @@ NSString * const NSMetadataQueryGatheringProgressNotification = @"NSMetadataQuer
|
|||
// Status of the query...
|
||||
- (BOOL)isStopped
|
||||
{
|
||||
[self subclassResponsibility: _cmd];
|
||||
return NO;
|
||||
return _isStopped;
|
||||
}
|
||||
|
||||
- (BOOL)isGathering
|
||||
{
|
||||
[self subclassResponsibility: _cmd];
|
||||
return NO;
|
||||
return _isGathering;
|
||||
}
|
||||
|
||||
- (BOOL)isStarted
|
||||
{
|
||||
[self subclassResponsibility: _cmd];
|
||||
return NO;
|
||||
return _isStarted;
|
||||
}
|
||||
|
||||
- (void)stopQuery
|
||||
|
@ -168,25 +178,23 @@ NSString * const NSMetadataQueryGatheringProgressNotification = @"NSMetadataQuer
|
|||
// Search URLS
|
||||
- (void)setSearchItemURLs:(NSArray *)urls
|
||||
{
|
||||
[self subclassResponsibility: _cmd];
|
||||
ASSIGNCOPY(_searchURLs,urls);
|
||||
}
|
||||
|
||||
- (NSArray *)searchItemURLs
|
||||
{
|
||||
[self subclassResponsibility: _cmd];
|
||||
return [NSArray array];
|
||||
return _searchURLs;
|
||||
}
|
||||
|
||||
// Search scopes
|
||||
- (void)setSearchScopes:(NSArray *)scopes
|
||||
{
|
||||
[self subclassResponsibility: _cmd];
|
||||
ASSIGNCOPY(_scopes,scopes);
|
||||
}
|
||||
|
||||
- (NSArray *)searchScopes
|
||||
{
|
||||
[self subclassResponsibility: _cmd];
|
||||
return [NSArray array];
|
||||
return _scopes;
|
||||
}
|
||||
|
||||
// Notification interval
|
||||
|
@ -225,39 +233,36 @@ NSString * const NSMetadataQueryGatheringProgressNotification = @"NSMetadataQuer
|
|||
}
|
||||
|
||||
// Sort descriptors
|
||||
- (void)setSortDescriptors:(NSArray *)attrs
|
||||
- (void)setSortDescriptors:(NSArray *)descriptors
|
||||
{
|
||||
[self subclassResponsibility: _cmd];
|
||||
ASSIGNCOPY(_sortDescriptors,descriptors);
|
||||
}
|
||||
|
||||
- (NSArray *)sortDescriptors
|
||||
{
|
||||
[self subclassResponsibility: _cmd];
|
||||
return [NSArray array];
|
||||
return _sortDescriptors;
|
||||
}
|
||||
|
||||
// Predicate
|
||||
- (void)setPredicate:(NSPredicate *)predicate
|
||||
{
|
||||
[self subclassResponsibility: _cmd];
|
||||
ASSIGNCOPY(_predicate,predicate);
|
||||
}
|
||||
|
||||
- (NSPredicate *)predicate
|
||||
{
|
||||
[self subclassResponsibility: _cmd];
|
||||
return nil;
|
||||
return _predicate;
|
||||
}
|
||||
|
||||
// Delegate
|
||||
- (void)setDelegate:(id<NSMetadataQueryDelegate>)delegate;
|
||||
{
|
||||
[self subclassResponsibility: _cmd];
|
||||
_delegate = delegate;
|
||||
}
|
||||
|
||||
- (id<NSMetadataQueryDelegate>)delegate;
|
||||
{
|
||||
[self subclassResponsibility: _cmd];
|
||||
return nil;
|
||||
return _delegate;
|
||||
}
|
||||
|
||||
@end
|
|
@ -37,7 +37,7 @@ win32_OBJC_FILES =\
|
|||
NSMessagePortNameServer.m \
|
||||
NSStream.m \
|
||||
NSUserDefaults.m \
|
||||
|
||||
NSMetadata.m
|
||||
|
||||
-include Makefile.preamble
|
||||
|
||||
|
|
321
Source/win32/NSMetadata.m
Normal file
321
Source/win32/NSMetadata.m
Normal file
|
@ -0,0 +1,321 @@
|
|||
/**Interface for NSMetadataQuery for GNUStep
|
||||
Copyright (C) 2012 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Gregory Casamento
|
||||
Date: 2012
|
||||
|
||||
This file is part of the GNUstep Base 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; if not, write to the Free
|
||||
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02111 USA.
|
||||
|
||||
AutogsdocSource: NSMetadata.m
|
||||
*/
|
||||
|
||||
#import "Foundation/NSMetadata.h"
|
||||
#import "Foundation/NSArray.h"
|
||||
#import "Foundation/NSDictionary.h"
|
||||
#import "Foundation/NSString.h"
|
||||
#import "Foundation/NSTimer.h"
|
||||
#import "GNUstepBase/NSObject+GNUstepBase.h"
|
||||
|
||||
// Metadata item constants...
|
||||
NSString * const NSMetadataItemFSNameKey = @"NSMetadataItemFSNameKey";
|
||||
NSString * const NSMetadataItemDisplayNameKey = @"NSMetadataItemDisplayNameKey";
|
||||
NSString * const NSMetadataItemURLKey = @"NSMetadataItemURLKey";
|
||||
NSString * const NSMetadataItemPathKey = @"NSMetadataItemPathKey";
|
||||
NSString * const NSMetadataItemFSSizeKey = @"NSMetadataItemFSSizeKey";
|
||||
NSString * const NSMetadataItemFSCreationDateKey = @"NSMetadataItemFSCreationDateKey";
|
||||
NSString * const NSMetadataItemFSContentChangeDateKey = @"NSMetadataItemFSContentChangeDateKey";
|
||||
|
||||
@implementation NSMetadataItem
|
||||
- (NSArray *)attributes
|
||||
{
|
||||
return [attributes allKeys];
|
||||
}
|
||||
|
||||
- (id)valueForAttribute: (NSString *)key
|
||||
{
|
||||
return [attributes objectForKey: key];
|
||||
}
|
||||
|
||||
- (NSDictionary *)valuesForAttributes: (NSArray *)keys
|
||||
{
|
||||
NSMutableDictionary *results = [NSMutableDictionary dictionary];
|
||||
NSEnumerator *en = [keys objectEnumerator];
|
||||
id key = nil;
|
||||
|
||||
while((key = [en nextObject]) != nil)
|
||||
{
|
||||
id value = [self valueForAttribute: key];
|
||||
[results setObject: value forKey: key];
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
// Metdata Query Constants...
|
||||
NSString * const NSMetadataQueryUserHomeScope = @"NSMetadataQueryUserHomeScope";
|
||||
NSString * const NSMetadataQueryLocalComputerScope = @"NSMetadataQueryLocalComputerScope";
|
||||
NSString * const NSMetadataQueryNetworkScope = @"NSMetadataQueryNetworkScope";
|
||||
NSString * const NSMetadataQueryUbiquitousDocumentsScope = @"NSMetadataQueryUbiquitousDocumentsScope";
|
||||
NSString * const NSMetadataQueryUbiquitousDataScope = @"NSMetadataQueryUbiquitousDataScope";
|
||||
|
||||
NSString * const NSMetadataQueryDidFinishGatheringNotification = @"NSMetadataQueryDidFinishGatheringNotification";
|
||||
NSString * const NSMetadataQueryDidStartGatheringNotification = @"NSMetadataQueryDidStartGatheringNotification";
|
||||
NSString * const NSMetadataQueryDidUpdateNotification = @"NSMetadataQueryDidUpdateNotification";
|
||||
NSString * const NSMetadataQueryGatheringProgressNotification = @"NSMetadataQueryGatheringProgressNotification";
|
||||
|
||||
@implementation NSMetadataQuery
|
||||
|
||||
- (id) init
|
||||
{
|
||||
if((self = [super init]) != nil)
|
||||
{
|
||||
_isStopped = YES;
|
||||
_isGathering = NO;
|
||||
_isStarted = NO;
|
||||
_notificationBatchingInterval = (NSTimeInterval)0.0;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
/* Instance methods */
|
||||
- (id)valueOfAttribute:(id)attr forResultAtIndex:(NSUInteger)index
|
||||
{
|
||||
[self subclassResponsibility: _cmd];
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (NSArray *)groupedResults;
|
||||
{
|
||||
[self subclassResponsibility: _cmd];
|
||||
return [NSArray array];
|
||||
}
|
||||
|
||||
- (NSDictionary *)valueLists
|
||||
{
|
||||
[self subclassResponsibility: _cmd];
|
||||
return [NSArray array];
|
||||
}
|
||||
|
||||
- (NSUInteger)indexOfResult:(id)result
|
||||
{
|
||||
[self subclassResponsibility: _cmd];
|
||||
return NSNotFound;
|
||||
}
|
||||
|
||||
- (NSArray *)results
|
||||
{
|
||||
[self subclassResponsibility: _cmd];
|
||||
return [NSArray array];
|
||||
}
|
||||
|
||||
- (id)resultAtIndex:(NSUInteger)index
|
||||
{
|
||||
[self subclassResponsibility: _cmd];
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (NSUInteger)resultCount
|
||||
{
|
||||
[self subclassResponsibility: _cmd];
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Enable/Disable updates
|
||||
- (void)enableUpdates
|
||||
{
|
||||
[self subclassResponsibility: _cmd];
|
||||
}
|
||||
|
||||
- (void)disableUpdates
|
||||
{
|
||||
[self subclassResponsibility: _cmd];
|
||||
}
|
||||
|
||||
// Status of the query...
|
||||
- (BOOL)isStopped
|
||||
{
|
||||
return _isStopped;
|
||||
}
|
||||
|
||||
- (BOOL)isGathering
|
||||
{
|
||||
return _isGathering;
|
||||
}
|
||||
|
||||
- (BOOL)isStarted
|
||||
{
|
||||
return _isStarted;
|
||||
}
|
||||
|
||||
- (void)stopQuery
|
||||
{
|
||||
[self subclassResponsibility: _cmd];
|
||||
}
|
||||
|
||||
- (BOOL)startQuery
|
||||
{
|
||||
[self subclassResponsibility: _cmd];
|
||||
return NO;
|
||||
}
|
||||
|
||||
// Search URLS
|
||||
- (void)setSearchItemURLs:(NSArray *)urls
|
||||
{
|
||||
ASSIGNCOPY(_searchURLs,urls);
|
||||
}
|
||||
|
||||
- (NSArray *)searchItemURLs
|
||||
{
|
||||
return _searchURLs;
|
||||
}
|
||||
|
||||
// Search scopes
|
||||
- (void)setSearchScopes:(NSArray *)scopes
|
||||
{
|
||||
ASSIGNCOPY(_scopes,scopes);
|
||||
}
|
||||
|
||||
- (NSArray *)searchScopes
|
||||
{
|
||||
return _scopes;
|
||||
}
|
||||
|
||||
// Notification interval
|
||||
- (void)setNotificationBatchingInterval:(NSTimeInterval)interval
|
||||
{
|
||||
[self subclassResponsibility: _cmd];
|
||||
}
|
||||
|
||||
- (NSTimeInterval)notificationBatchingInterval
|
||||
{
|
||||
[self subclassResponsibility: _cmd];
|
||||
return (NSTimeInterval)0;
|
||||
}
|
||||
|
||||
// Grouping Attributes.
|
||||
- (void)setGroupingAttributes:(NSArray *)attrs
|
||||
{
|
||||
[self subclassResponsibility: _cmd];
|
||||
}
|
||||
|
||||
- (NSArray *)groupingAttributes
|
||||
{
|
||||
[self subclassResponsibility: _cmd];
|
||||
return [NSArray array];
|
||||
}
|
||||
|
||||
- (void)setValueListAttributes:(NSArray *)attrs
|
||||
{
|
||||
[self subclassResponsibility: _cmd];
|
||||
}
|
||||
|
||||
- (NSArray *)valueListAttributes
|
||||
{
|
||||
[self subclassResponsibility: _cmd];
|
||||
return [NSArray array];
|
||||
}
|
||||
|
||||
// Sort descriptors
|
||||
- (void)setSortDescriptors:(NSArray *)descriptors
|
||||
{
|
||||
ASSIGNCOPY(_sortDescriptors,descriptors);
|
||||
}
|
||||
|
||||
- (NSArray *)sortDescriptors
|
||||
{
|
||||
return _sortDescriptors;
|
||||
}
|
||||
|
||||
// Predicate
|
||||
- (void)setPredicate:(NSPredicate *)predicate
|
||||
{
|
||||
ASSIGNCOPY(_predicate,predicate);
|
||||
}
|
||||
|
||||
- (NSPredicate *)predicate
|
||||
{
|
||||
return _predicate;
|
||||
}
|
||||
|
||||
// Delegate
|
||||
- (void)setDelegate:(id<NSMetadataQueryDelegate>)delegate;
|
||||
{
|
||||
_delegate = delegate;
|
||||
}
|
||||
|
||||
- (id<NSMetadataQueryDelegate>)delegate;
|
||||
{
|
||||
return _delegate;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation NSMetadataQueryAttributeValueTuple
|
||||
|
||||
- (NSString *) attribute
|
||||
{
|
||||
return _attribute;
|
||||
}
|
||||
|
||||
- (id) value
|
||||
{
|
||||
return _value;
|
||||
}
|
||||
|
||||
- (NSUInteger) count
|
||||
{
|
||||
return _count;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation NSMetadataQueryResultGroup : NSObject
|
||||
|
||||
- (NSString *) attribute
|
||||
{
|
||||
return _attribute;
|
||||
}
|
||||
|
||||
- (id) value
|
||||
{
|
||||
return _value;
|
||||
}
|
||||
|
||||
- (NSArray *) subgroups
|
||||
{
|
||||
return _subgroups;
|
||||
}
|
||||
|
||||
- (NSUInteger) resultCount
|
||||
{
|
||||
return [_subgroups count];
|
||||
}
|
||||
|
||||
- (id) resultAtIndex: (NSUInteger)index
|
||||
{
|
||||
return [_subgroups objectAtIndex:index];
|
||||
}
|
||||
|
||||
- (NSArray *) results
|
||||
{
|
||||
return [self subgroups];
|
||||
}
|
||||
|
||||
@end
|
Loading…
Reference in a new issue