//
//  TIDeviceObject.h
//  Device Explorer
//
//  Created by otusweb on Wed May 08 2002.
//  Copyright (c) 2002 Texas Instruments Incorporated. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <Cocoa/Cocoa.h>

// keys for attributes:
/*"name of this bundle, mainly used inside the bundle itself"*/
extern NSString *bundleName;

/*"key used when returning a dictionary"*/
extern NSString *errorNumber;
extern NSString *errorString;


@class TIDeviceFolder, TIDevice;

@interface TIDeviceObject : NSObject  <NSCopying>
{
    NSString *_name;				/*"displayable Name of the object"*/
    NSString *_internalName;			/*"name used passed in by ti connect manager"*/
    NSString *_kind;				/*"kind of the object, store a human readable string"*/
    NSNumber *_size;				/*"Size of the file in Bytes"*/
    TIDeviceFolder *_container;			/*"Container of the object"*/
    NSImage *_iconImage;			/*"the image used to represent this guy"*/
    BOOL _isLeaf;				/*"wether this guy can have any children"*/
    NSArray *flags;				/*"flag of the file can be locked, archived or none"*/
    IBOutlet id delegate;			/*"Delegate of the object will receive the callback for asynchronous operations"*/
    NSString *nonHumanReadableKind;
}
/*"initializer"*/
- (id) initWithContainer: (TIDeviceFolder*) inContainer
                    name: (NSString*)inName
            internalName: (NSString*)inInternalName
    nonHumanReadableKind: (NSString*)inKind
                    size: (NSNumber*)inSize
               iconImage: (NSImage*)inImage
                   flags: (NSArray*) inFlag;


/*"Accessors"*/
- (NSString*) fileType;
- (NSString *) name;
- (NSString *) internalName;
- (NSString *) kind;
- (NSNumber *) size;
- (NSArray *) flags;
- (TIDeviceFolder *) container;
- (BOOL) isLeaf;
- (NSImage *) iconImage;
- (void) setIconImage: (NSImage*) toValue;
- (TIDevice*) device;
- (NSString *) nonHumanReadableKind;
- (void) setNonHumanReadableKind:(NSString *)newNonHumanReadableKind;
- (id) delegate;
- (void) setDelegate:(id)newDelegate;
- (void) objectPropertyWithCode: (NSString*) property
            callingCompletionOn: (id) target
                        context:(id) context;
- (NSAppleEventDescriptor*) objectPropertyWithCode: (NSString*) property;
- (void) setObjectPropertyWithCode: (NSString*) property
                           toValue: (NSAppleEventDescriptor*) toValue
               callingCompletionOn: (id) target
                           context:(id) context;
- (NSAppleEventDescriptor*) setObjectPropertyWithCode: (NSString*) property toValue: (NSAppleEventDescriptor*) toValue;
+ (NSBundle*) frameworkBundle;

/*"ObjectSpecifier function"*/
- (NSAppleEventDescriptor*) makeSpecifier;

/*"Comparator"*/
- (NSComparisonResult)nameComparison:(TIDeviceObject*)otherObject;
- (NSComparisonResult)sizeComparison:(TIDeviceObject*)otherObject;
- (NSComparisonResult)kindComparison:(TIDeviceObject*)otherObject;

/*" setter for editable properties, those will send appleevents to the come manager"*/
-(NSDictionary*) sendValueForname:(NSString*) inName;

/*"Utility function"*/
- (NSAppleEventDescriptor*) buildAppleEventOfClass: (AEEventClass) inClass
                                       withEventID: (AEEventID) theID
                           withRandomTransactionID: (BOOL) inRandomTransaction
                                        withFormat: (const char *) paramsFmt,...;
- (NSString*) path;
- (NSString*) deviceRelativePath;
+ (NSAppleEventDescriptor*) buildAEListOfDeviceObjects: (NSArray*) inDeviceList;
+ (NSArray*) deviceOfFiles: (NSArray*) inFileList;
@end

@interface NSObject (TIDeviceObjectCompletionRoutine)
- (void) deviceObject:(TIDeviceObject*) sender receivedProperty: (NSAppleEventDescriptor*) inResult property: (NSString*) propertyAsked context:(id) context;
- (void) deviceObject:(TIDeviceObject*) sender setProperty: (NSString*) propertySet result: (NSAppleEventDescriptor*) inResult context:(id) context;
@end

NSAppleEventDescriptor *TIGetContentsOfFile(NSURL *inFileURL);
NSAppleEventDescriptor *TICoerceDescriptor(NSAppleEventDescriptor *inDesc, DescType toType);
BOOL TIFileCheckName(NSString* inName, DescType inDocumentType);
void TIQuitComManager(BOOL forceIfNecessary);